From d72ecb5b3b799cb16360214c38c6c0907fb60993 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Tue, 11 Jan 2022 09:07:21 +0530 Subject: [PATCH 1/2] port _ctypes --- Modules/_ctypes/_ctypes.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 96078c7726d597..624835f3d44bd3 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5668,13 +5668,6 @@ wstring_at(const wchar_t *ptr, int size) } -static struct PyModuleDef _ctypesmodule = { - PyModuleDef_HEAD_INIT, - .m_name = "_ctypes", - .m_doc = module_docs, - .m_size = -1, - .m_methods = _ctypes_module_methods, -}; static int @@ -5847,20 +5840,25 @@ _ctypes_mod_exec(PyObject *mod) return 0; } +static struct PyModuleDef_Slot _ctypes_slots[] = { + {Py_mod_exec, _ctypes_mod_exec}, + {0, NULL} +}; + +static struct PyModuleDef _ctypesmodule = { + PyModuleDef_HEAD_INIT, + .m_name = "_ctypes", + .m_doc = module_docs, + .m_size = 0, + .m_methods = _ctypes_module_methods, + .m_slots = _ctypes_slots, +}; + PyMODINIT_FUNC PyInit__ctypes(void) { - PyObject *mod = PyModule_Create(&_ctypesmodule); - if (!mod) { - return NULL; - } - - if (_ctypes_mod_exec(mod) < 0) { - Py_DECREF(mod); - return NULL; - } - return mod; + return PyModuleDef_Init(&_ctypesmodule); } /* From 3aaf3ecce196a01bbed69989b399cafc1e1effdc Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 03:56:43 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2022-01-11-03-56-42.bpo-1635741.Vrjfuk.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-01-11-03-56-42.bpo-1635741.Vrjfuk.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-01-11-03-56-42.bpo-1635741.Vrjfuk.rst b/Misc/NEWS.d/next/Core and Builtins/2022-01-11-03-56-42.bpo-1635741.Vrjfuk.rst new file mode 100644 index 00000000000000..ea1c1f1986b692 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-01-11-03-56-42.bpo-1635741.Vrjfuk.rst @@ -0,0 +1 @@ +Port _ctypes extension module to multiphase initialization. \ No newline at end of file