mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
Return None to signal that the module the object was defined in was not found when object has no __name__ attr but is needed to figure out location of object.
This commit is contained in:
parent
424a415951
commit
4a671fe634
1 changed files with 2 additions and 0 deletions
|
|
@ -383,6 +383,8 @@ def getmodule(object):
|
|||
if file in modulesbyfile:
|
||||
return sys.modules.get(modulesbyfile[file])
|
||||
main = sys.modules['__main__']
|
||||
if not hasattr(object, '__name__'):
|
||||
return None
|
||||
if hasattr(main, object.__name__):
|
||||
mainobject = getattr(main, object.__name__)
|
||||
if mainobject is object:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue