diff options
author | Ka-Ping Yee <ping@zesty.ca> | 2001-03-02 01:19:39 (GMT) |
---|---|---|
committer | Ka-Ping Yee <ping@zesty.ca> | 2001-03-02 01:19:39 (GMT) |
commit | 7a25765f48dbd6697c346559f75aa1ce08d91a5a (patch) | |
tree | 42f1ba44d19873deb7d4376f74d4d84e8b0aad9e /Lib/inspect.py | |
parent | a2fe103c9b75b20f2cd1362b7ecbd7edff1fc66c (diff) | |
download | cpython-7a25765f48dbd6697c346559f75aa1ce08d91a5a.zip cpython-7a25765f48dbd6697c346559f75aa1ce08d91a5a.tar.gz cpython-7a25765f48dbd6697c346559f75aa1ce08d91a5a.tar.bz2 |
When seeking the module for an object, compare absolute (not relative) paths.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 240ff1d..ac0ee44 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -27,7 +27,7 @@ Here are some of the useful functions provided by this module: __author__ = 'Ka-Ping Yee <ping@lfw.org>' __date__ = '1 Jan 2001' -import sys, types, string, dis, imp, tokenize +import sys, os, types, string, dis, imp, tokenize # ----------------------------------------------------------- type-checking def ismodule(object): @@ -199,14 +199,15 @@ def getmodule(object): if isclass(object): return sys.modules.get(object.__module__) try: - file = getsourcefile(object) + file = os.path.abspath(getsourcefile(object)) except TypeError: return None if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): - modulesbyfile[getsourcefile(module)] = module.__name__ + modulesbyfile[ + os.path.abspath(getsourcefile(module))] = module.__name__ if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] |