@@ -25,7 +25,7 @@ See ``tests.pyx`` for extensive tests.
2525
2626from libc.signal cimport *
2727from 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
2929from cpython.exc cimport (PyErr_Occurred, PyErr_NormalizeException,
3030 PyErr_Fetch, PyErr_Restore)
3131from cpython.version cimport PY_MAJOR_VERSION
@@ -360,7 +360,7 @@ cdef void verify_exc_value() noexcept:
360360 Check that ``cysigs.exc_value`` is still the exception being raised.
361361 Clear ``cysigs.exc_value`` if not.
362362 """
363- if cysigs.exc_value.ob_refcnt == 1 :
363+ if cysigs.exc_value ! = NULL and _Py_REFCNT(cysigs.exc_value) == 1 :
364364 # No other references => exception is certainly gone
365365 Py_CLEAR(cysigs.exc_value)
366366 return
@@ -408,5 +408,5 @@ cdef void verify_exc_value() noexcept:
408408 # Make sure we still have cysigs.exc_value at all; if this function was
409409 # called again during garbage collection it might have already been set
410410 # 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 :
412412 Py_CLEAR(cysigs.exc_value)
0 commit comments