[pypy-commit] pypy py3k: issue #1603: fix the default get_printable_location potentially releasing the

pjenvey noreply at buildbot.pypy.org
Wed Sep 18 01:26:34 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r66993:464c7c15c57c
Date: 2013-09-17 16:25 -0700
http://bitbucket.org/pypy/pypy/changeset/464c7c15c57c/

Log:	issue #1603: fix the default get_printable_location potentially
	releasing the GIL via get_repr

diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py
--- a/pypy/interpreter/pycode.py
+++ b/pypy/interpreter/pycode.py
@@ -417,13 +417,17 @@
         return space.newtuple([new_inst, space.newtuple(tup)])
 
     def get_repr(self):
+        # This is called by the default get_printable_location so it
+        # must avoid doing too much (that might release the gil)
+        return '<code object %s, file "%s", line %d>' % (
+            self.co_name, self.co_filename,
+            -1 if self.co_firstlineno == 0 else self.co_firstlineno)
+
+    def repr(self, space):
         space = self.space
         # co_name should be an identifier
         name = self.co_name.decode('utf-8')
         fn = space.fsdecode_w(space.wrapbytes(self.co_filename))
-        return u'<code object %s at 0x%s, file "%s", line %d>' % (
+        return space.wrap(u'<code object %s at 0x%s, file "%s", line %d>' % (
             name, unicode(self.getaddrstring(space)), fn,
-            -1 if self.co_firstlineno == 0 else self.co_firstlineno)
-
-    def repr(self, space):
-        return space.wrap(self.get_repr())
+            -1 if self.co_firstlineno == 0 else self.co_firstlineno))
diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -31,10 +31,7 @@
     from pypy.tool.stdlib_opcode import opcode_method_names
     from rpython.rlib.runicode import unicode_encode_utf_8
     name = opcode_method_names[ord(bytecode.co_code[next_instr])]
-    repru = bytecode.get_repr()
-    # XXX: lame
-    reprs = unicode_encode_utf_8(repru, len(repru), "replace")
-    return '%s #%d %s' % (reprs, next_instr, name)
+    return '%s #%d %s' % (bytecode.get_repr(), next_instr, name)
 
 def get_jitcell_at(next_instr, is_being_profiled, bytecode):
     # use only uints as keys in the jit_cells dict, rather than


More information about the pypy-commit mailing list