[Python-checkins] r50719 - in python/trunk/Lib: inspect.py test/test_inspect.py
phillip.eby
python-checkins at python.org
Thu Jul 20 17:54:16 CEST 2006
Author: phillip.eby
Date: Thu Jul 20 17:54:16 2006
New Revision: 50719
Modified:
python/trunk/Lib/inspect.py
python/trunk/Lib/test/test_inspect.py
Log:
Fix SF#1516184 (again) and add a test to prevent regression.
(There was a problem with empty filenames still causing recursion)
Modified: python/trunk/Lib/inspect.py
==============================================================================
--- python/trunk/Lib/inspect.py (original)
+++ python/trunk/Lib/inspect.py Thu Jul 20 17:54:16 2006
@@ -364,8 +364,9 @@
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 = {}
Modified: python/trunk/Lib/test/test_inspect.py
==============================================================================
--- python/trunk/Lib/test/test_inspect.py (original)
+++ python/trunk/Lib/test/test_inspect.py Thu Jul 20 17:54:16 2006
@@ -187,6 +187,7 @@
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
More information about the Python-checkins
mailing list