Commits

Benjamin Peterson committed edd1997

bumping the extended_arg_count is not equivalent to reresolving jump targets

This should fix issue #713.

Comments (0)

Files changed (2)

pypy/interpreter/astcompiler/assemble.py

         while True:
             extended_arg_count = 0
             offset = 0
+            force_redo = False
             # Calculate the code offset of each block.
             for block in blocks:
                 block.offset = offset
                                     instr.has_jump = False
                                     # The size of the code changed,
                                     # we have to trigger another pass
-                                    extended_arg_count += 1
+                                    force_redo = True
                                     continue
                         if absolute:
                             jump_arg = target.offset
                         instr.arg = jump_arg
                         if jump_arg > 0xFFFF:
                             extended_arg_count += 1
-            if extended_arg_count == last_extended_arg_count:
+            if extended_arg_count == last_extended_arg_count and not force_redo:
                 break
             else:
                 last_extended_arg_count = extended_arg_count

pypy/interpreter/astcompiler/test/test_compiler.py

     def error_test(self, source, exc_type):
         py.test.raises(exc_type, self.simple_test, source, None, None)
 
+    def test_issue_713(self):
+        func = "def f(_=2): return (_ if _ else _) if False else _"
+        yield self.st, func, "f()", 2
+
     def test_long_jump(self):
         func = """def f(x):
     y = 0