Skip to content

Commit a5b54ca

Browse files
committed
Remove sig_occurred check in fast_tp_dealloc
1 parent d82cfd3 commit a5b54ca

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/sage/rings/integer.pyx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ from libc.string cimport memcpy
149149
from libc.limits cimport LONG_MAX
150150

151151
from cysignals.memory cimport check_allocarray, check_malloc, sig_free
152-
from cysignals.signals cimport sig_on, sig_off, sig_check, sig_occurred
152+
from cysignals.signals cimport sig_on, sig_off, sig_check
153153

154154
import operator
155155

@@ -7687,26 +7687,22 @@ cdef void fast_tp_dealloc(PyObject* o) noexcept:
76877687

76887688
cdef mpz_ptr o_mpz = <mpz_ptr>((<Integer>o).value)
76897689

7690-
# If we are recovering from an interrupt, throw the mpz_t away
7691-
# without recycling or freeing it because it might be in an
7692-
# inconsistent state (see Issue #24986).
7693-
if sig_occurred() is NULL:
7694-
if integer_pool_count < integer_pool_size:
7695-
# Here we free any extra memory used by the mpz_t by
7696-
# setting it to a single limb.
7697-
if o_mpz._mp_alloc > 10:
7698-
_mpz_realloc(o_mpz, 1)
7699-
7700-
# It's cheap to zero out an integer, so do it here.
7701-
o_mpz._mp_size = 0
7702-
7703-
# And add it to the pool.
7704-
integer_pool[integer_pool_count] = o
7705-
integer_pool_count += 1
7706-
return
7707-
7708-
# No space in the pool, so just free the mpz_t.
7709-
mpz_clear(o_mpz)
7690+
if integer_pool_count < integer_pool_size:
7691+
# Here we free any extra memory used by the mpz_t by
7692+
# setting it to a single limb.
7693+
if o_mpz._mp_alloc > 10:
7694+
_mpz_realloc(o_mpz, 1)
7695+
7696+
# It's cheap to zero out an integer, so do it here.
7697+
o_mpz._mp_size = 0
7698+
7699+
# And add it to the pool.
7700+
integer_pool[integer_pool_count] = o
7701+
integer_pool_count += 1
7702+
return
7703+
7704+
# No space in the pool, so just free the mpz_t.
7705+
mpz_clear(o_mpz)
77107706

77117707
# Free the object. This assumes that Py_TPFLAGS_HAVE_GC is not
77127708
# set. If it was set another free function would need to be

0 commit comments

Comments
 (0)