From: Brett Cannon Date: Sun, 15 Jun 2003 22:33:28 +0000 (+0000) Subject: Return None to signal that the module the object was defined in was not found when... X-Git-Tag: v2.3c1~426 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a671fe6341235fc4a06a9ed7d788394f54d3fea;p=python 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. --- diff --git a/Lib/inspect.py b/Lib/inspect.py index a2ea7390bd..eca5e8ca78 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: