Skip to content

Commit

Permalink
Make module lookup a little more robust (certain kinds of fiddling to
Browse files Browse the repository at this point in the history
    sys.modules previously produced an exception).
  • Loading branch information
zestyping committed Mar 28, 2003
1 parent e9638cc commit b38bbbd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ def getmodule(object):
except TypeError:
return None
if file in modulesbyfile:
return sys.modules[modulesbyfile[file]]
return sys.modules.get(modulesbyfile[file])
for module in sys.modules.values():
if hasattr(module, '__file__'):
modulesbyfile[getabsfile(module)] = module.__name__
if file in modulesbyfile:
return sys.modules[modulesbyfile[file]]
return sys.modules.get(modulesbyfile[file])
main = sys.modules['__main__']
if hasattr(main, object.__name__):
mainobject = getattr(main, object.__name__)
Expand Down

0 comments on commit b38bbbd

Please sign in to comment.