Commits

Philip Jenvey  committed 464c7c1

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

  • Participants
  • Parent commits f1a61a8
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/interpreter/pycode.py

         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))

File pypy/module/pypyjit/interp_jit.py

     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