diff options
author | Ka-Ping Yee <ping@zesty.ca> | 2001-04-13 12:10:40 (GMT) |
---|---|---|
committer | Ka-Ping Yee <ping@zesty.ca> | 2001-04-13 12:10:40 (GMT) |
commit | c99e0f18628b1b6109c88aa31a44a19d34c7d103 (patch) | |
tree | 8d8c6529859b55a076411ddff28547c211356e4f /Lib/inspect.py | |
parent | da79389f100366a4e221e30b45da6f33e6f8ec34 (diff) | |
download | cpython-c99e0f18628b1b6109c88aa31a44a19d34c7d103.zip cpython-c99e0f18628b1b6109c88aa31a44a19d34c7d103.tar.gz cpython-c99e0f18628b1b6109c88aa31a44a19d34c7d103.tar.bz2 |
Robustify getfile() against classes that lie about their __module__s
(such as the exceptions in _weakref and _locale!)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index f62167b..c358a5c 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -173,7 +173,7 @@ def getfile(object): return object.__file__ raise TypeError, 'arg is a built-in module' if isclass(object): - object = sys.modules[object.__module__] + object = sys.modules.get(object.__module__) if hasattr(object, '__file__'): return object.__file__ raise TypeError, 'arg is a built-in class' |