mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-124153: Remove _PyType_GetModuleByDef2
private function (GH-124261)
Thank you!
This commit is contained in:
parent
2c472d36b7
commit
d7248cdbc3
4 changed files with 26 additions and 46 deletions
|
@ -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));
|
||||
|
||||
|
@ -5241,7 +5241,7 @@ get_module_by_def(PyTypeObject *type, PyModuleDef *def)
|
|||
Py_ssize_t n = PyTuple_GET_SIZE(mro);
|
||||
for (Py_ssize_t i = 1; i < n; i++) {
|
||||
PyObject *super = PyTuple_GET_ITEM(mro, i);
|
||||
if(!_PyType_HasFeature((PyTypeObject *)super, Py_TPFLAGS_HEAPTYPE)) {
|
||||
if (!_PyType_HasFeature((PyTypeObject *)super, Py_TPFLAGS_HEAPTYPE)) {
|
||||
// Static types in the MRO need to be skipped
|
||||
continue;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue