@@ -953,12 +953,12 @@ class ExceptNonlocalControl(CleanupNonlocalControl):
953
953
Just makes sure that sys.exc_info always gets restored when we leave.
954
954
This is super annoying.
955
955
"""
956
- def __init__ (self , outer : NonlocalControl , saved : Value ) -> None :
956
+ def __init__ (self , outer : NonlocalControl , saved : Union [ Value , AssignmentTarget ] ) -> None :
957
957
super ().__init__ (outer )
958
958
self .saved = saved
959
959
960
960
def gen_cleanup (self , builder : 'IRBuilder' , line : int ) -> None :
961
- builder .primitive_op (restore_exc_info_op , [self .saved ], line )
961
+ builder .primitive_op (restore_exc_info_op , [builder . read ( self .saved ) ], line )
962
962
963
963
964
964
class FinallyNonlocalControl (CleanupNonlocalControl ):
@@ -3550,7 +3550,7 @@ def visit_try_except(self,
3550
3550
# exception is raised, based on the exception in exc_info.
3551
3551
self .error_handlers .append (double_except_block )
3552
3552
self .activate_block (except_entry )
3553
- old_exc = self .primitive_op (error_catch_op , [], line )
3553
+ old_exc = self .maybe_spill ( self . primitive_op (error_catch_op , [], line ) )
3554
3554
# Compile the except blocks with the nonlocal control flow overridden to clear exc_info
3555
3555
self .nonlocal_control .append (
3556
3556
ExceptNonlocalControl (self .nonlocal_control [- 1 ], old_exc ))
@@ -3583,14 +3583,14 @@ def visit_try_except(self,
3583
3583
# restore the saved exc_info information and continue propagating
3584
3584
# the exception if it exists.
3585
3585
self .activate_block (cleanup_block )
3586
- self .primitive_op (restore_exc_info_op , [old_exc ], line )
3586
+ self .primitive_op (restore_exc_info_op , [self . read ( old_exc ) ], line )
3587
3587
self .goto (exit_block )
3588
3588
3589
3589
# Cleanup for if we leave except through a raised exception:
3590
3590
# restore the saved exc_info information and continue propagating
3591
3591
# the exception.
3592
3592
self .activate_block (double_except_block )
3593
- self .primitive_op (restore_exc_info_op , [old_exc ], line )
3593
+ self .primitive_op (restore_exc_info_op , [self . read ( old_exc ) ], line )
3594
3594
self .primitive_op (keep_propagating_op , [], NO_TRACEBACK_LINE_NO )
3595
3595
self .add (Unreachable ())
3596
3596
0 commit comments