]> granicus.if.org Git - python/commitdiff
'inspect' was not listing the functions in a module properly if the module was
authorBrett Cannon <bcannon@gmail.com>
Fri, 13 Aug 2004 18:46:24 +0000 (18:46 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 13 Aug 2004 18:46:24 +0000 (18:46 +0000)
reached through a symlink (was comparing path of module to path to function and
were not matching because of the symlink).  os.path.realpath() is now used to
solve this discrepency.

Closes bug #570300.  Thanks Johannes Gijsbers for the fix.

Lib/inspect.py
Misc/NEWS

index 12c9cb757b7f0c72678099b9a49646e70bfa126f..7f732649c8265b48fd1808d5df23bfc347d18ece 100644 (file)
@@ -380,7 +380,9 @@ def getmodule(object):
         return sys.modules.get(modulesbyfile[file])
     for module in sys.modules.values():
         if hasattr(module, '__file__'):
-            modulesbyfile[getabsfile(module)] = module.__name__
+            modulesbyfile[
+                os.path.realpath(
+                        getabsfile(module))] = module.__name__
     if file in modulesbyfile:
         return sys.modules.get(modulesbyfile[file])
     main = sys.modules['__main__']
index c1c78677ec871bbf0f4dc21b595f291b5d85c4b9..9ee04499a0474b566e3baea6325fadb59961c68e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -41,6 +41,10 @@ Extension modules
 Library
 -------
 
+- bug #570300: Fix inspect to resolve file locations using os.path.realpath()
+  so as to properly list all functions in a module when the module itself is
+  reached through a symlink.  Thanks Johannes Gijsbers.
+
 - doctest refactoring continued.  See the docs for details.  As part of
   this effort, some old and little- (never?) used features are now
   deprecated:  the Tester class, the module is_private() function, and the