]> granicus.if.org Git - python/commitdiff
Fix SF#1516184 (again) and add a test to prevent regression.
authorPhillip J. Eby <pje@telecommunity.com>
Thu, 20 Jul 2006 15:54:16 +0000 (15:54 +0000)
committerPhillip J. Eby <pje@telecommunity.com>
Thu, 20 Jul 2006 15:54:16 +0000 (15:54 +0000)
(There was a problem with empty filenames still causing recursion)

Lib/inspect.py
Lib/test/test_inspect.py

index 311fe7ec697ff242be49d2f3f646f71b4d69b673..dc2fa0818063a6ecce0475dd302a5fad6be6ac5c 100644 (file)
@@ -364,8 +364,9 @@ def getabsfile(object, _filename=None):
 
     The idea is for each object to have a unique origin, so this routine
     normalizes the result as much as possible."""
-    return os.path.normcase(
-        os.path.abspath(_filename or getsourcefile(object) or getfile(object)))
+    if _filename is None:
+        _filename = getsourcefile(object) or getfile(object)
+    return os.path.normcase(os.path.abspath(_filename))
 
 modulesbyfile = {}
 
index 912a24fc5a8055a06d7b4ddcceafd87c6f54b125..76f2566e509f2681396a15f413db3ce76ddf8b76 100644 (file)
@@ -187,6 +187,7 @@ class TestRetrievingSourceCode(GetSourceBase):
         exec "def x(): pass" in m.__dict__
         self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
         del sys.modules[name]
+        inspect.getmodule(compile('a=10','','single'))
 
 class TestDecorators(GetSourceBase):
     fodderFile = mod2