summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorneonene <53406459+neonene@users.noreply.github.com>2024-09-26 16:21:11 (GMT)
committerGitHub <noreply@github.com>2024-09-26 16:21:11 (GMT)
commitd7248cdbc32ffb401a27499223b7f0c2f80614f8 (patch)
tree282b935a4d83fca07bf2e90fbc1afb2d54c9842a /Objects
parent2c472d36b776636fb00881a717f69e43672588b1 (diff)
downloadcpython-d7248cdbc32ffb401a27499223b7f0c2f80614f8.zip
cpython-d7248cdbc32ffb401a27499223b7f0c2f80614f8.tar.gz
cpython-d7248cdbc32ffb401a27499223b7f0c2f80614f8.tar.bz2
gh-124153: Remove `_PyType_GetModuleByDef2` private function (GH-124261)
Thank you!
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 68e481f..3368c1e 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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;
}