@@ -18,8 +18,10 @@ from __future__ import absolute_import, division, print_function
18
18
cimport cython
19
19
20
20
from cpython.ref cimport PyObject, Py_XINCREF, Py_XDECREF
21
+ from cpython.exc cimport PyErr_SetString
21
22
22
- from cysignals.signals cimport sig_on, sig_off, sig_block, sig_unblock
23
+ from cysignals.signals cimport (sig_on, sig_off, sig_block, sig_unblock,
24
+ sig_error)
23
25
from cysignals.memory cimport check_malloc, sig_free
24
26
25
27
from .gen cimport Gen, Gen_new
@@ -52,6 +54,9 @@ cdef void remove_from_pari_stack(Gen self):
52
54
print (" ERROR: removing wrong instance of Gen" )
53
55
print (f" Expected: {<object>stackbottom}" )
54
56
print (f" Actual: {self}" )
57
+ if sig_on_count and not block_sigint:
58
+ PyErr_SetString(SystemError , " calling remove_from_pari_stack() inside sig_on()" )
59
+ sig_error()
55
60
if self .sp() != avma:
56
61
if avma > self .sp():
57
62
print (" ERROR: inconsistent avma when removing Gen from PARI stack" )
@@ -60,8 +65,6 @@ cdef void remove_from_pari_stack(Gen self):
60
65
else :
61
66
warn(f" cypari2 leaked {self.sp() - avma} bytes on the PARI stack" ,
62
67
RuntimeWarning , stacklevel = 2 )
63
- if sig_on_count and not block_sigint:
64
- print (f" ERROR: sig_on_count = {sig_on_count} during remove_from_pari_stack()" )
65
68
n = self .next
66
69
stackbottom = < PyObject* > n
67
70
self .next = None
0 commit comments