@@ -25,7 +25,7 @@ See ``tests.pyx`` for extensive tests.
25
25
26
26
from libc.signal cimport *
27
27
from libc.stdio cimport freopen, stdin
28
- from cpython.ref cimport Py_XINCREF, Py_CLEAR
28
+ from cpython.ref cimport Py_XINCREF, Py_CLEAR, _Py_REFCNT
29
29
from cpython.exc cimport (PyErr_Occurred, PyErr_NormalizeException,
30
30
PyErr_Fetch, PyErr_Restore)
31
31
from cpython.version cimport PY_MAJOR_VERSION
@@ -360,7 +360,7 @@ cdef void verify_exc_value() noexcept:
360
360
Check that ``cysigs.exc_value`` is still the exception being raised.
361
361
Clear ``cysigs.exc_value`` if not.
362
362
"""
363
- if cysigs.exc_value.ob_refcnt == 1 :
363
+ if cysigs.exc_value ! = NULL and _Py_REFCNT(cysigs.exc_value) == 1 :
364
364
# No other references => exception is certainly gone
365
365
Py_CLEAR(cysigs.exc_value)
366
366
return
@@ -408,5 +408,5 @@ cdef void verify_exc_value() noexcept:
408
408
# Make sure we still have cysigs.exc_value at all; if this function was
409
409
# called again during garbage collection it might have already been set
410
410
# to NULL; see https://github.com/sagemath/cysignals/issues/126
411
- if cysigs.exc_value != NULL and cysigs.exc_value.ob_refcnt == 1 :
411
+ if cysigs.exc_value != NULL and _Py_REFCNT( cysigs.exc_value) == 1 :
412
412
Py_CLEAR(cysigs.exc_value)
0 commit comments