diff options
author | Brett Cannon <bcannon@gmail.com> | 2003-06-15 22:33:28 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2003-06-15 22:33:28 (GMT) |
commit | 4a671fe6341235fc4a06a9ed7d788394f54d3fea (patch) | |
tree | 92df16cf57189c606f1c2d5f120f4507983d11d8 /Lib/inspect.py | |
parent | 424a41595166235fdefa33108cde3ea4341dace8 (diff) | |
download | cpython-4a671fe6341235fc4a06a9ed7d788394f54d3fea.zip cpython-4a671fe6341235fc4a06a9ed7d788394f54d3fea.tar.gz cpython-4a671fe6341235fc4a06a9ed7d788394f54d3fea.tar.bz2 |
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.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index a2ea739..eca5e8c 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -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: |