[py-svn] r9341 - py/dist/py/code

hpk at codespeak.net hpk at codespeak.net
Sat Feb 19 16:23:08 CET 2005


Author: hpk
Date: Sat Feb 19 16:23:08 2005
New Revision: 9341

Modified:
   py/dist/py/code/source.py
Log:
if the filename arg doesn't exist or is not True 
then append the generated-at information always. 



Modified: py/dist/py/code/source.py
==============================================================================
--- py/dist/py/code/source.py	(original)
+++ py/dist/py/code/source.py	Sat Feb 19 16:23:08 2005
@@ -1,6 +1,7 @@
 from __future__ import generators
 import sys
 import inspect
+import py
 cpy_compile = compile 
 
 # DON'T IMPORT PY HERE
@@ -171,10 +172,10 @@
             invent an artificial filename which displays
             the source/line position of the caller frame.
         """
-        if filename is None:
+        if not filename or py.path.local(filename).check(file=0): 
             frame = sys._getframe(1) # the caller
-            filename = '<%s:%d>' % (frame.f_code.co_filename,
-                                    frame.f_lineno)
+            filename = '%s<%s:%d>' % (filename, frame.f_code.co_filename,
+                                      frame.f_lineno)
         source = str(self)+'\n'
         try:
             co = cpy_compile(source, filename, mode, flag)



More information about the pytest-commit mailing list