[Python-checkins] bpo-1635741: Port fcntl module to multiphase initialization (GH-20540)

Dong-hee Na webhook-mailer at python.org
Mon Jun 1 12:12:32 EDT 2020


https://github.com/python/cpython/commit/e9684fac5a158be9806304a676e619857520a4dc
commit: e9684fac5a158be9806304a676e619857520a4dc
branch: master
author: Dong-hee Na <donghee.na92 at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-06-02T01:12:24+09:00
summary:

bpo-1635741: Port fcntl module to multiphase initialization (GH-20540)

files:
A Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-23-35.bpo-1635741.0D-laM.rst
M Modules/fcntlmodule.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-23-35.bpo-1635741.0D-laM.rst b/Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-23-35.bpo-1635741.0D-laM.rst
new file mode 100644
index 0000000000000..cd2bcb6e60877
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-23-35.bpo-1635741.0D-laM.rst	
@@ -0,0 +1 @@
+Port :mod:`fcntl` to multiphase initialization.
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index 43f9b22f67207..39baea01ec84e 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);
 }



More information about the Python-checkins mailing list