]> granicus.if.org Git - python/commitdiff
Return None to signal that the module the object was defined in was not found when...
authorBrett Cannon <bcannon@gmail.com>
Sun, 15 Jun 2003 22:33:28 +0000 (22:33 +0000)
committerBrett Cannon <bcannon@gmail.com>
Sun, 15 Jun 2003 22:33:28 +0000 (22:33 +0000)
Lib/inspect.py

index a2ea7390bdbb47bd8849bc61d0cfde1ee10688c4..eca5e8ca78ef88cde32faa4bfeafab293096695d 100644 (file)
@@ -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: