summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-06-01 16:12:24 (GMT)
committerGitHub <noreply@github.com>2020-06-01 16:12:24 (GMT)
commite9684fac5a158be9806304a676e619857520a4dc (patch)
tree5ded4e26c2d7b12edca0ab0a7dc50a164d6f0240 /Modules
parentc8966667bbdb284c3780ef6cec8a3870935a6bb7 (diff)
downloadcpython-e9684fac5a158be9806304a676e619857520a4dc.zip
cpython-e9684fac5a158be9806304a676e619857520a4dc.tar.gz
cpython-e9684fac5a158be9806304a676e619857520a4dc.tar.bz2
bpo-1635741: Port fcntl module to multiphase initialization (GH-20540)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/fcntlmodule.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index 43f9b22..39baea0 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -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);
}