Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-1635741 port some simple modules to multi-phase initialization #21985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
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 55 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);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.