Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-124153: Remove _PyType_GetModuleByDef2 private function #124262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion 1 Include/internal/pycore_typeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ extern PyObject * _PyType_GetBases(PyTypeObject *type);
extern PyObject * _PyType_GetMRO(PyTypeObject *type);
extern PyObject* _PyType_GetSubclasses(PyTypeObject *);
extern int _PyType_HasSubclasses(PyTypeObject *);
PyAPI_FUNC(PyObject *) _PyType_GetModuleByDef2(PyTypeObject *, PyTypeObject *, PyModuleDef *);

// Export for _testinternalcapi extension.
PyAPI_FUNC(PyObject *) _PyType_GetSlotWrapperNames(void);
Expand Down
31 changes: 4 additions & 27 deletions 31 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
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.