Skip to content

Commit

Permalink
move get_module_by_def() into PyType_GetModuleByDef()
Browse files Browse the repository at this point in the history
  • Loading branch information
neonene authored Sep 20, 2024
1 parent 7a2d77c commit bb37f41
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5207,8 +5207,8 @@ PyType_GetModuleState(PyTypeObject *type)
/* Get the module of the first superclass where the module has the
* given PyModuleDef.
*/
static inline PyObject *
get_module_by_def(PyTypeObject *type, PyModuleDef *def)
PyObject *
PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
{
assert(PyType_Check(type));

Expand Down Expand Up @@ -5254,37 +5254,14 @@ get_module_by_def(PyTypeObject *type, PyModuleDef *def)
}
}
END_TYPE_LOCK();
return res;
}

PyObject *
PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
{
PyObject *module = get_module_by_def(type, def);
if (module == NULL) {
if (res == NULL) {
PyErr_Format(
PyExc_TypeError,
"PyType_GetModuleByDef: No superclass of '%s' has the given module",
type->tp_name);
}
return module;
}

PyObject *
_PyType_GetModuleByDef2(PyTypeObject *left, PyTypeObject *right,
PyModuleDef *def)
{
PyObject *module = get_module_by_def(left, def);
if (module == NULL) {
module = get_module_by_def(right, def);
if (module == NULL) {
PyErr_Format(
PyExc_TypeError,
"PyType_GetModuleByDef: No superclass of '%s' nor '%s' has "
"the given module", left->tp_name, right->tp_name);
}
}
return module;
return res;
}


Expand Down

0 comments on commit bb37f41

Please sign in to comment.