Skip to content
Closed
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
Next Next commit
port termios to multi-phase
  • Loading branch information
koubaa committed Aug 12, 2020
commit a7e0a9890fb37883acfd1b05254f007be7237fdc
55 changes: 28 additions & 27 deletions Modules/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,37 +997,14 @@ static void termiosmodule_free(void *m) {
termiosmodule_clear((PyObject *)m);
}

static struct PyModuleDef termiosmodule = {
PyModuleDef_HEAD_INIT,
"termios",
termios__doc__,
sizeof(termiosmodulestate),
termios_methods,
NULL,
termiosmodule_traverse,
termiosmodule_clear,
termiosmodule_free,
};

PyMODINIT_FUNC
PyInit_termios(void)
static int
termios_exec(PyModule *m)
{
PyObject *m;
struct constant *constant = termios_constants;

if ((m = PyState_FindModule(&termiosmodule)) != NULL) {
Py_INCREF(m);
return m;
}

if ((m = PyModule_Create(&termiosmodule)) == NULL) {
return NULL;
}

termiosmodulestate *state = get_termios_state(m);
state->TermiosError = PyErr_NewException("termios.error", NULL, NULL);
if (state->TermiosError == NULL) {
return NULL;
return -1;
}
Py_INCREF(state->TermiosError);
PyModule_AddObject(m, "error", state->TermiosError);
Expand All @@ -1036,5 +1013,29 @@ PyInit_termios(void)
PyModule_AddIntConstant(m, constant->name, constant->value);
++constant;
}
return m;
return 0;
}

static PyModuleDef_Slot termios_slots[] = {
{Py_mod_exec, termios_exec},
{0, NULL}
};



static struct PyModuleDef termiosmodule = {
PyModuleDef_HEAD_INIT,
.m_name = "termios",
.m_doc = termios__doc__,
.m_size = sizeof(termiosmodulestate),
.m_methods = termios_methods,
.m_slots = termios_slots,
.m_traverse = termiosmodule_traverse,
.m_clear = termiosmodule_clear,
.m_free = termiosmodule_free,
};


PyMODINIT_FUNC PyInit_termios(void) {
return PyModuleDef_Init(&termiosmodule);
}