117
117
from mypyc .primitives .misc_ops import (
118
118
check_stop_op ,
119
119
coro_op ,
120
+ debug_print_op ,
120
121
import_from_many_op ,
121
122
import_many_op ,
122
123
import_op ,
@@ -1036,16 +1037,21 @@ def try_body() -> None:
1036
1037
def except_body () -> None :
1037
1038
exc_original = builder .call_c (get_exc_value_op , [], line )
1038
1039
1039
- builder .py_call (builder .py_get_attr (gen , "throw" , line ), [], line )
1040
- err_occurred = builder .call_c (err_occurred_op , [], line )
1041
-
1042
1040
error_block , no_error_block = BasicBlock (), BasicBlock ()
1043
- builder .add (Branch (err_occurred , error_block , no_error_block , Branch .BOOL ))
1044
1041
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 ())
1046
1051
1052
+ builder .activate_block (error_block )
1047
1053
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 )
1049
1055
1050
1056
suppress_block , propagate_block = BasicBlock (), BasicBlock ()
1051
1057
builder .add (Branch (is_same_exc , suppress_block , propagate_block , Branch .BOOL ))
@@ -1054,10 +1060,6 @@ def except_body() -> None:
1054
1060
builder .call_c (keep_propagating_op , [], line )
1055
1061
builder .add (Unreachable ())
1056
1062
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
-
1061
1063
builder .activate_block (suppress_block )
1062
1064
builder .call_c (error_clear_op , [], - 1 )
1063
1065
0 commit comments