From 953b7bfb1d5e96ca6ea994cd923f11d20d7acef8 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 30 May 2020 23:24:03 +0900 Subject: [PATCH] bpo-1635741: Port fcntl module to multiphase initialization --- ...2020-05-30-23-23-35.bpo-1635741.0D-laM.rst | 1 + Modules/fcntlmodule.c | 41 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-05-30-23-23-35.bpo-1635741.0D-laM.rst 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 00000000000000..cd2bcb6e60877a --- /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 43f9b22f672070..39baea01ec84ea 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); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy