Skip to content

Commit 1ab1f16

Browse files
committed
even more context
1 parent 1dfbcb4 commit 1ab1f16

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

mypyc/irbuild/statement.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
from mypyc.primitives.misc_ops import (
118118
check_stop_op,
119119
coro_op,
120+
debug_print_op,
120121
import_from_many_op,
121122
import_many_op,
122123
import_op,
@@ -1036,16 +1037,21 @@ def try_body() -> None:
10361037
def except_body() -> None:
10371038
exc_original = builder.call_c(get_exc_value_op, [], line)
10381039

1039-
builder.py_call(builder.py_get_attr(gen, "throw", line), [], line)
1040-
err_occurred = builder.call_c(err_occurred_op, [], line)
1041-
10421040
error_block, no_error_block = BasicBlock(), BasicBlock()
1043-
builder.add(Branch(err_occurred, error_block, no_error_block, Branch.BOOL))
10441041

1045-
builder.activate_block(error_block)
1042+
builder.builder.push_error_handler(error_block)
1043+
builder.goto_and_activate(BasicBlock())
1044+
builder.py_call(builder.py_get_attr(gen, "throw", line), [exc_original], line)
1045+
builder.goto(no_error_block)
1046+
builder.builder.pop_error_handler()
1047+
1048+
builder.activate_block(no_error_block)
1049+
builder.add(RaiseStandardError(RaiseStandardError.RUNTIME_ERROR, "generator didn't stop after throw()", line))
1050+
builder.add(Unreachable())
10461051

1052+
builder.activate_block(error_block)
10471053
stop_iteration = builder.call_c(check_stop_op, [], line)
1048-
is_same_exc = builder.binary_op(stop_iteration, exc_original, "is", line)
1054+
is_same_exc = builder.binary_op(stop_iteration, exc_original, "==", line)
10491055

10501056
suppress_block, propagate_block = BasicBlock(), BasicBlock()
10511057
builder.add(Branch(is_same_exc, suppress_block, propagate_block, Branch.BOOL))
@@ -1054,10 +1060,6 @@ def except_body() -> None:
10541060
builder.call_c(keep_propagating_op, [], line)
10551061
builder.add(Unreachable())
10561062

1057-
builder.activate_block(no_error_block)
1058-
builder.add(RaiseStandardError(RaiseStandardError.RUNTIME_ERROR, "generator didn't stop after throw()", line))
1059-
builder.add(Unreachable())
1060-
10611063
builder.activate_block(suppress_block)
10621064
builder.call_c(error_clear_op, [], -1)
10631065

0 commit comments

Comments
 (0)