Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r76368:f3d8768ebb1c
Date: 2015-03-14 16:03 +0100
http://bitbucket.org/pypy/pypy/changeset/f3d8768ebb1c/

Log:    When translating PyPy, freeze the file name
        "<builtin>/lastdirname/basename.py" instead of freezing the complete
        translation-time path.

diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -4,7 +4,7 @@
 The bytecode interpreter itself is implemented by the PyFrame class.
 """
 
-import dis, imp, struct, types, new, sys
+import dis, imp, struct, types, new, sys, os
 
 from pypy.interpreter import eval
 from pypy.interpreter.signature import Signature
@@ -128,6 +128,15 @@
         if (self.magic == cpython_magic and
             '__pypy__' not in sys.builtin_module_names):
             raise Exception("CPython host codes should not be rendered")
+        # When translating PyPy, freeze the file name
+        #     <builtin>/lastdirname/basename.py
+        # instead of freezing the complete translation-time path.
+        filename = self.co_filename.lstrip('<').rstrip('>')
+        if filename.lower().endswith('.pyc'):
+            filename = filename[:-1]
+        basename = os.path.basename(filename)
+        lastdirname = os.path.basename(os.path.dirname(filename))
+        self.co_filename = '<builtin>/%s/%s' % (lastdirname, basename)
 
     co_names = property(lambda self: [self.space.unwrap(w_name) for w_name in 
self.co_names_w]) # for trace
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to