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 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); } /* 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