Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
minor changes
  • Loading branch information
koubaa committed Sep 8, 2020
commit 9d593d7f9a4cd8671f9128a10f09a4507c0be812
34 changes: 20 additions & 14 deletions Modules/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ indexing in the cc array must be done using the symbolic constants defined\n\
in this module.");

static PyObject *
termios_tcgetattr(PyObject *self, PyObject *args)
termios_tcgetattr(PyObject *module, PyObject *args)
{
int fd;
if (!PyArg_ParseTuple(args, "O&:tcgetattr",
fdconv, (void*)&fd)) {
return NULL;
}

termiosmodulestate *state = PyModule_GetState(self);
termiosmodulestate *state = PyModule_GetState(module);
struct termios mode;
if (tcgetattr(fd, &mode) == -1) {
return PyErr_SetFromErrno(state->TermiosError);
Expand Down Expand Up @@ -155,7 +155,7 @@ queued output, or termios.TCSAFLUSH to change after transmitting all\n\
queued output and discarding all queued input. ");

static PyObject *
termios_tcsetattr(PyObject *self, PyObject *args)
termios_tcsetattr(PyObject *module, PyObject *args)
{
int fd, when;
PyObject *term;
Expand All @@ -171,7 +171,7 @@ termios_tcsetattr(PyObject *self, PyObject *args)
}

/* Get the old mode, in case there are any hidden fields... */
termiosmodulestate *state = PyModule_GetState(self);
termiosmodulestate *state = PyModule_GetState(module);
struct termios mode;
if (tcgetattr(fd, &mode) == -1) {
return PyErr_SetFromErrno(state->TermiosError);
Expand Down Expand Up @@ -229,15 +229,15 @@ A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
has a system dependent meaning.");

static PyObject *
termios_tcsendbreak(PyObject *self, PyObject *args)
termios_tcsendbreak(PyObject *module, PyObject *args)
{
int fd, duration;
if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
fdconv, &fd, &duration)) {
return NULL;
}

termiosmodulestate *state = PyModule_GetState(self);
termiosmodulestate *state = PyModule_GetState(module);
if (tcsendbreak(fd, duration) == -1) {
return PyErr_SetFromErrno(state->TermiosError);
}
Expand All @@ -251,15 +251,15 @@ PyDoc_STRVAR(termios_tcdrain__doc__,
Wait until all output written to file descriptor fd has been transmitted.");

static PyObject *
termios_tcdrain(PyObject *self, PyObject *args)
termios_tcdrain(PyObject *module, PyObject *args)
{
int fd;
if (!PyArg_ParseTuple(args, "O&:tcdrain",
fdconv, &fd)) {
return NULL;
}

termiosmodulestate *state = PyModule_GetState(self);
termiosmodulestate *state = PyModule_GetState(module);
if (tcdrain(fd) == -1) {
return PyErr_SetFromErrno(state->TermiosError);
}
Expand All @@ -276,15 +276,15 @@ queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
both queues. ");

static PyObject *
termios_tcflush(PyObject *self, PyObject *args)
termios_tcflush(PyObject *module, PyObject *args)
{
int fd, queue;
if (!PyArg_ParseTuple(args, "O&i:tcflush",
fdconv, &fd, &queue)) {
return NULL;
}

termiosmodulestate *state = PyModule_GetState(self);
termiosmodulestate *state = PyModule_GetState(module);
if (tcflush(fd, queue) == -1) {
return PyErr_SetFromErrno(state->TermiosError);
}
Expand All @@ -301,15 +301,15 @@ termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
or termios.TCION to restart input.");

static PyObject *
termios_tcflow(PyObject *self, PyObject *args)
termios_tcflow(PyObject *module, PyObject *args)
{
int fd, action;
if (!PyArg_ParseTuple(args, "O&i:tcflow",
fdconv, &fd, &action)) {
return NULL;
}

termiosmodulestate *state = PyModule_GetState(self);
termiosmodulestate *state = PyModule_GetState(module);
if (tcflow(fd, action) == -1) {
return PyErr_SetFromErrno(state->TermiosError);
}
Expand Down Expand Up @@ -1022,10 +1022,16 @@ termios_exec(PyObject *mod)
return -1;
}
Py_INCREF(state->TermiosError);
PyModule_AddObject(mod, "error", state->TermiosError);
if (PyModule_AddObject(mod, "error", state->TermiosError) < 0) {
Py_DECREF(state->TermiosError);
return -1;
}

while (constant->name != NULL) {
PyModule_AddIntConstant(mod, constant->name, constant->value);
if (PyModule_AddIntConstant(
mod, constant->name, constant->value) < 0) {
return -1;
}
++constant;
}
return 0;
Expand Down