Skip to content

Commit 4010185

Browse files
committed
Create new object every exception
1 parent 5a5ab72 commit 4010185

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/sage/libs/gap/util.pyx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,6 @@ cdef Obj gap_eval(str gap_string) except? NULL:
444444
############################################################################
445445

446446

447-
cdef object keyboard_interrupt_exc = KeyboardInterrupt(), alarm_interrupt_exc = KeyboardInterrupt("alarm interrupt")
448-
449-
450-
try:
451-
from cysignals.signals import AlarmInterrupt
452-
except ImportError:
453-
pass
454-
else:
455-
alarm_interrupt_exc = AlarmInterrupt()
456-
457-
458447
class GAPError(ValueError): # ValueError for historical reasons
459448
"""
460449
Exceptions raised by the GAP library
@@ -534,11 +523,14 @@ cdef void error_handler() noexcept with gil:
534523
# Note that we manually need to deal with refcounts here.
535524
if last_signum:
536525
if last_signum == SIGINT:
537-
exc_type = <PyObject*>Py_TYPE(keyboard_interrupt_exc)
538-
exc_val = <PyObject*>keyboard_interrupt_exc
526+
exc_type = <PyObject*>KeyboardInterrupt
527+
exc_val_python = KeyboardInterrupt()
528+
exc_val = <PyObject*>exc_val_python
539529
elif last_signum == SIGALRM:
540-
exc_type = <PyObject*>Py_TYPE(alarm_interrupt_exc)
541-
exc_val = <PyObject*>alarm_interrupt_exc
530+
from cysignals.signals import AlarmInterrupt
531+
exc_type = <PyObject*>AlarmInterrupt
532+
exc_val_python = AlarmInterrupt()
533+
exc_val = <PyObject*>exc_val_python
542534
else:
543535
msg = f'{msg}\nunexpected signal value {last_signum} handled, this cannot happen'
544536
exc_type = <PyObject*>GAPError

0 commit comments

Comments
 (0)