]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43770: Cleanup PyModuleDef_Init() (GH-26879)
authorVictor Stinner <vstinner@python.org>
Wed, 23 Jun 2021 13:40:27 +0000 (15:40 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Jun 2021 13:40:27 +0000 (15:40 +0200)
PyModuleDef_Init() no longer tries to make PyModule_Type type: it's
already done by _PyTypes_Init() at Python startup. Replace
PyType_Ready() call with an assertion.

Objects/moduleobject.c

index 61478a1c4817c924c55a69a14b8f975bdc5f726d..ef39bde4e425d56ea95105c25cfdce07bff92fc3 100644 (file)
@@ -46,8 +46,7 @@ _PyModule_IsExtension(PyObject *obj)
 PyObject*
 PyModuleDef_Init(struct PyModuleDef* def)
 {
-    if (PyType_Ready(&PyModuleDef_Type) < 0)
-         return NULL;
+    assert(PyModuleDef_Type.tp_flags & Py_TPFLAGS_READY);
     if (def->m_base.m_index == 0) {
         max_module_number++;
         Py_SET_REFCNT(def, 1);