diff options
author | 2010-06-06 17:07:03 +0000 | |
---|---|---|
committer | 2010-06-06 17:07:03 +0000 | |
commit | 95e4ad2aad101c653f898260c75cf645966d6871 (patch) | |
tree | 94395f681e55bcf311bfc73adb9273ff13bce4b6 /py | |
parent | Merge encodings-unfreeze branch. This should kill freezing of encodings (diff) | |
download | pypy-95e4ad2aad101c653f898260c75cf645966d6871.tar.gz pypy-95e4ad2aad101c653f898260c75cf645966d6871.tar.bz2 pypy-95e4ad2aad101c653f898260c75cf645966d6871.zip |
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)
Diffstat (limited to 'py')
-rw-r--r-- | py/_code/source.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/py/_code/source.py b/py/_code/source.py index 1eb4dcc861..87e61d4d12 100644 --- a/py/_code/source.py +++ b/py/_code/source.py @@ -17,6 +17,7 @@ class Source(object): """ 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 @@ class Source(object): 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) |