Skip to content
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

bpo-1635741: Port fcntl module to multiphase initialization #20540

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Port :mod:`fcntl` to multiphase initialization.
41 changes: 19 additions & 22 deletions Modules/fcntlmodule.c
Original file line number Diff line number Diff line change
@@ -662,34 +662,31 @@ all_ins(PyObject* m)
return 0;
}

static int
fcntl_exec(PyObject *module)
{
if (all_ins(module) < 0) {
return -1;
}
return 0;
}

static PyModuleDef_Slot fcntl_slots[] = {
{Py_mod_exec, fcntl_exec},
{0, NULL}
};

static struct PyModuleDef fcntlmodule = {
PyModuleDef_HEAD_INIT,
"fcntl",
module_doc,
-1,
fcntl_methods,
NULL,
NULL,
NULL,
NULL
.m_name = "fcntl",
.m_doc = module_doc,
.m_size = 0,
.m_methods = fcntl_methods,
.m_slots = fcntl_slots,
};

PyMODINIT_FUNC
PyInit_fcntl(void)
{
PyObject *m;

/* Create the module and add the functions and documentation */
m = PyModule_Create(&fcntlmodule);
if (m == NULL)
return NULL;

/* Add some symbolic constants to the module */
if (all_ins(m) < 0) {
Py_DECREF(m);
return NULL;
}

return m;
return PyModuleDef_Init(&fcntlmodule);
}