]> granicus.if.org Git - python/commitdiff
When seeking the module for an object, compare absolute (not relative) paths.
authorKa-Ping Yee <ping@zesty.ca>
Fri, 2 Mar 2001 01:19:39 +0000 (01:19 +0000)
committerKa-Ping Yee <ping@zesty.ca>
Fri, 2 Mar 2001 01:19:39 +0000 (01:19 +0000)
Lib/inspect.py

index 240ff1d38a0f47baadd55caa1fa88c474fa17fd7..ac0ee44ccd35cf3ffaa62a8e76a3ecfa29bf4463 100644 (file)
@@ -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__']