mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
In whichmodule(), use __module__ if set.
This commit is contained in:
parent
b6c935a933
commit
4518823ad0
1 changed files with 4 additions and 0 deletions
|
@ -632,6 +632,10 @@ whichmodule(PyObject *global, PyObject *global_name) {
|
|||
PyObject *module = 0, *modules_dict = 0,
|
||||
*global_name_attr = 0, *name = 0;
|
||||
|
||||
module = PyObject_GetAttrString(global, "__module__");
|
||||
if (module) return module;
|
||||
PyErr_Clear();
|
||||
|
||||
if ((module = PyDict_GetItem(class_map, global))) {
|
||||
Py_INCREF(module);
|
||||
return module;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue