8000 bpo-1635741: Port fcntl module to multiphase initialization (GH-20540) · python/cpython@e9684fa · GitHub
[go: up one dir, main page]

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

Commit e9684fa

Browse files
authored
bpo-1635741: Port fcntl module to multiphase initialization (GH-20540)
1 parent c896666 commit e9684fa

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Port :mod:`fcntl` to multiphase initialization.

Modules/fcntlmodule.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -662,34 +662,31 @@ all_ins(PyObject* m)
662662
return 0;
663663
}
664664

665+
static int
666+
fcntl_exec(PyObject *module)
667+
{
668+
if (all_ins(module) < 0) {
669+
return -1;
670+
}
671+
return 0;
672+
}
673+
674+
static PyModuleDef_Slot fcntl_slots[] = {
675+
{Py_mod_exec, fcntl_exec},
676+
{0, NULL}
677+
};
665678

666679
static struct PyModuleDef fcntlmodule = {
667680
PyModuleDef_HEAD_INIT,
668-
"fcntl",
669-
module_doc,
670-
-1,
671-
fcntl_methods,
672-
NULL,
673-
NULL,
674-
NULL,
675-
NULL
681+
.m_name = "fcntl",
682+
.m_doc = module_doc,
683+
.m_size = 0,
684+
.m_methods = fcntl_methods,
685+
.m_slots = fcntl_slots,
676686
};
677687

678688
PyMODINIT_FUNC
679689
PyInit_fcntl(void)
680690
{
681-
PyObject *m;
682-
683-
/* Create the module and add the functions and documentation */
684-
m = PyModule_Create(&fcntlmodule);
685-
if (m == NULL)
686-
return NULL;
687-
688-
/* Add some symbolic constants to the module */
689-
if (all_ins(m) < 0) {
690-
Py_DECREF(m);
691-
return NULL;
692-
}
693-
694-
return m;
691+
return PyModuleDef_Init(&fcntlmodule);
695692
}

0 commit comments

Comments
 (0)
0