Commit 1a2959cf authored by Phillip J. Eby's avatar Phillip J. Eby

Fix SF#1516184 (again) and add a test to prevent regression.

(There was a problem with empty filenames still causing recursion)
parent cfe3128c
......@@ -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 = {}
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment