[pypy-svn] r75153 - pypy/trunk/py/_code

hpk at codespeak.net hpk at codespeak.net
Sun Jun 6 19:07:04 CEST 2010


Author: hpk
Date: Sun Jun  6 19:07:03 2010
New Revision: 75153

Modified:
   pypy/trunk/py/_code/source.py
Log:
also copy the py.code.compile fix to trunk (it can obscure/fail on traceback-printing, especially with generated code entries being in the traceback)


Modified: pypy/trunk/py/_code/source.py
==============================================================================
--- pypy/trunk/py/_code/source.py	(original)
+++ pypy/trunk/py/_code/source.py	Sun Jun  6 19:07:03 2010
@@ -17,6 +17,7 @@
     """ a immutable object holding a source code fragment,
         possibly deindenting it.
     """
+    _compilecounter = 0
     def __init__(self, *parts, **kwargs):
         self.lines = lines = []
         de = kwargs.get('deindent', True)
@@ -195,10 +196,12 @@
             if _genframe is None:
                 _genframe = sys._getframe(1) # the caller
             fn,lineno = _genframe.f_code.co_filename, _genframe.f_lineno
+            base = "<%d-codegen " % self._compilecounter
+            self.__class__._compilecounter += 1
             if not filename:
-                filename = '<codegen %s:%d>' % (fn, lineno)
+                filename = base + '%s:%d>' % (fn, lineno)
             else:
-                filename = '<codegen %r %s:%d>' % (filename, fn, lineno)
+                filename = base + '%r %s:%d>' % (filename, fn, lineno)
         source = "\n".join(self.lines) + '\n'
         try:
             co = cpy_compile(source, filename, mode, flag)



More information about the Pypy-commit mailing list