Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/cysignals/signals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ See ``tests.pyx`` for extensive tests.

from libc.signal cimport *
from libc.stdio cimport freopen, stdin
from cpython.ref cimport Py_XINCREF, Py_XDECREF
from cpython.ref cimport Py_XINCREF, Py_CLEAR
from cpython.exc cimport (PyErr_Occurred, PyErr_NormalizeException,
PyErr_Fetch, PyErr_Restore)
from cpython.version cimport PY_MAJOR_VERSION
Expand Down Expand Up @@ -204,7 +204,7 @@ cdef int sig_raise_exception "sig_raise_exception"(int sig, const char* msg) exc
PyErr_Fetch(&typ, &val, &tb)
PyErr_NormalizeException(&typ, &val, &tb)
Py_XINCREF(val)
Py_XDECREF(cysigs.exc_value)
Py_CLEAR(cysigs.exc_value)
cysigs.exc_value = val
PyErr_Restore(typ, val, tb)

Expand Down Expand Up @@ -362,8 +362,7 @@ cdef void verify_exc_value() noexcept:
"""
if cysigs.exc_value.ob_refcnt == 1:
# No other references => exception is certainly gone
Py_XDECREF(cysigs.exc_value)
cysigs.exc_value = NULL
Py_CLEAR(cysigs.exc_value)
return

if PyErr_Occurred() is not NULL:
Expand Down Expand Up @@ -394,8 +393,7 @@ cdef void verify_exc_value() noexcept:
pass
else:
if <PyObject*>handled is cysigs.exc_value:
Py_XDECREF(cysigs.exc_value)
cysigs.exc_value = NULL
Py_CLEAR(cysigs.exc_value)
return

# To be safe, we run the garbage collector because it may clear
Expand All @@ -411,5 +409,4 @@ cdef void verify_exc_value() noexcept:
# called again during garbage collection it might have already been set
# to NULL; see https://github.com/sagemath/cysignals/issues/126
if cysigs.exc_value != NULL and cysigs.exc_value.ob_refcnt == 1:
Py_XDECREF(cysigs.exc_value)
cysigs.exc_value = NULL
Py_CLEAR(cysigs.exc_value)
Loading