summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2003-06-15 22:33:28 (GMT)
committerBrett Cannon <bcannon@gmail.com>2003-06-15 22:33:28 (GMT)
commit4a671fe6341235fc4a06a9ed7d788394f54d3fea (patch)
tree92df16cf57189c606f1c2d5f120f4507983d11d8 /Lib/inspect.py
parent424a41595166235fdefa33108cde3ea4341dace8 (diff)
downloadcpython-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.py2
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: