File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ from libc.errno cimport errno
35
35
from posix.signal cimport sigaltstack, stack_t, SS_ONSTACK
36
36
37
37
from cpython cimport PyErr_SetString
38
+ from cpython.exc cimport PyErr_CheckSignals
38
39
39
40
from .signals cimport *
40
41
from .memory cimport *
@@ -805,6 +806,13 @@ def test_interrupt_bomb(long n=100, long p=10):
805
806
i = 0
806
807
while True :
807
808
try :
809
+ # For some reason, without the line below, the exception
810
+ # will be detected too late (outside the try/except block)
811
+ # and the KeyboardInterrupt will be leaked outside,
812
+ # making the test fail.
813
+ # We can't really call PyErr_CheckSignals() from inside
814
+ # sig_on() because it does not hold the GIL.
815
+ PyErr_CheckSignals()
808
816
with nogil:
809
817
sig_on()
810
818
ms_sleep(1000 )
@@ -1124,7 +1132,7 @@ def test_sig_block_outside_sig_on(long delay=DEFAULT_DELAY):
1124
1132
sig_unblock()
1125
1133
1126
1134
try :
1127
- sig_on () # Interrupt caught here
1135
+ PyErr_CheckSignals () # Interrupt caught here
1128
1136
except KeyboardInterrupt :
1129
1137
return " Success"
1130
1138
abort() # This should not be reached
You can’t perform that action at this time.
0 commit comments