diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py index 7b58d749968..fd6b568b5d9 100644 --- a/pypy/interpreter/astcompiler/assemble.py +++ b/pypy/interpreter/astcompiler/assemble.py @@ -519,7 +519,7 @@ def _stacksize_error_pos(self, depth, blocks, block, instr): self._stack_depth_debug_print(blocks, block, instr) os.write(2, "StackDepthComputationError(POS) in %s at %s:%s depth %s\n" % (self.compile_info.filename, self.name, self.first_lineno, depth)) - #raise StackDepthComputationError # would-be-nice-not-to-have + raise StackDepthComputationError # would-be-nice-not-to-have def _stack_depth_debug_print(self, blocks, errorblock, errorinstr): print "\n" * 5 @@ -569,6 +569,8 @@ def _do_stack_depth_walk(self, block, blocks): for instr in block.instructions: orig_depth = depth depth += _opcode_stack_effect(instr.opcode, instr.arg) + if not we_are_translated(): + instr._stack_depth_after = depth if depth < 0: # This is really a fatal error, don't comment out this # 'raise'. It means that the stack depth computation @@ -601,8 +603,6 @@ def _do_stack_depth_walk(self, block, blocks): break elif jump_op == ops.RERAISE: break - if not we_are_translated(): - instr._stack_depth_after = depth else: if block.next_block: self._next_stack_depth_walk(block.next_block, depth, (block, None)) diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py index a698f5a7a02..c2a435a0eb2 100644 --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -1049,7 +1049,6 @@ def visit_TryStar(self, tr): [] L0: """ - import pdb; pdb.set_trace() body = self.new_block() exc = self.new_block() # L1 in comment above otherwise = self.new_block() # L0 in comment above @@ -1141,6 +1140,7 @@ def visit_TryStar(self, tr): self.emit_jump(ops.POP_JUMP_IF_FALSE, reraise_block) self.emit_op(ops.POP_TOP) self.emit_op(ops.POP_EXCEPT) + self.emit_op(ops.POP_TOP) # pypy difference: get rid of unroller self.emit_jump(ops.JUMP_FORWARD, otherwise) self.use_next_block(reraise_block) @@ -2978,6 +2978,8 @@ def view(startblock): for i, block in enumerate(blocks): name = blocknames[block] label = ["pos in blocks: %s/%s\\n" % (i + 1, len(blocks))] + if hasattr(block, 'initial_depth'): + label.append('initial stack depth: %s' % (block.initial_depth, )) if block.marked != 0: label.append("marked: %s\\n" % block.marked) @@ -2990,6 +2992,10 @@ def view(startblock): str_instr = "%5s: %s" % (instr.position_info[0], ops.opname[instr.opcode]) if instr.opcode >= ops.HAVE_ARGUMENT and instr.jump is None: str_instr += " %s" % (instr.arg, ) + if hasattr(instr, '_stack_depth_after'): + str_instr += " stack depth after: %s" % instr._stack_depth_after + if instr._stack_depth_after < 0 and instr._stack_depth_after != -99: + fillcolor = "red" label.append(str_instr) if instr.jump is not None: graph.emit_node(name, shape="box", label="\\l".join(label), fillcolor=fillcolor, color=color) diff --git a/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py b/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py index d35cb9f7005..76bb2aac469 100644 --- a/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py +++ b/pypy/interpreter/astcompiler/test/apptest_exceptiongroup.py @@ -83,3 +83,5 @@ def test_try_star_name_raise_in_except_handler(): assert "ZeroDivisionError" in repr(e) with raises(UnboundLocalError): e1 + + diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py index 19c0c581e6f..c359d647f39 100644 --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -179,8 +179,6 @@ def dispatch_bytecode(self, co_code, next_instr, ec): opcode = ord(co_code[next_instr]) oparg = ord(co_code[next_instr + 1]) next_instr += 2 - if self.pycode.co_name =='raises_one' and next_instr == 76: - import pdb;pdb.set_trace() # note: the structure of the code here is such that it makes # (after translation) a big "if/elif" chain, which is then @@ -1301,8 +1299,6 @@ def WITH_EXCEPT_START(self, oparg, next_instr): self.pushvalue(w_res) def RERAISE(self, reset_last_instr, next_instr): - if self.pycode.co_name == "raises_one": - import pdb;pdb.set_trace() unroller = self.popvalue() if not isinstance(unroller, SApplicationException): assert 0 @@ -1792,7 +1788,6 @@ def CHECK_EG_MATCH(self, oparg, next_instr): w_typ = self.popvalue() check_except_star_type_valid(self, w_typ) w_eg = self.peekvalue() - import pdb; pdb.set_trace() w_match, w_rest = exception_group_match(space, w_eg, w_typ) if space.is_w(w_match, space.w_None): self.pushvalue(w_match) @@ -1805,7 +1800,6 @@ def PREP_RERAISE_STAR(self, oparg, next_instr): w_res = self.popvalue() w_orig = self.popvalue() w_mod = space.call_method(space.builtin, '__import__', space.newtext('_pypy_exceptiongroups')) - import pdb; pdb.set_trace() w_eg_or_None = space.call_method(w_mod, "_prep_reraise_star", w_orig, w_res) if space.is_w(w_eg_or_None, space.w_None): w_push = space.w_None