diff --git a/src/greenlet/PyGreenlet.cpp b/src/greenlet/PyGreenlet.cpp index 29c0bba0..67a9a728 100644 --- a/src/greenlet/PyGreenlet.cpp +++ b/src/greenlet/PyGreenlet.cpp @@ -249,7 +249,7 @@ _green_dealloc_kill_started_non_main_greenlet(BorrowedGreenlet self) PyObject_GC_Track((PyObject*)self); - _Py_DEC_REFTOTAL; + GREENLET_Py_DEC_REFTOTAL; #ifdef COUNT_ALLOCS --Py_TYPE(self)->tp_frees; --Py_TYPE(self)->tp_allocs; diff --git a/src/greenlet/greenlet_cpython_compat.hpp b/src/greenlet/greenlet_cpython_compat.hpp index 979d6f94..a3b3850e 100644 --- a/src/greenlet/greenlet_cpython_compat.hpp +++ b/src/greenlet/greenlet_cpython_compat.hpp @@ -73,7 +73,9 @@ Greenlet won't compile on anything older than Python 3.11 alpha 4 (see # define Py_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #endif -#ifndef _Py_DEC_REFTOTAL +#ifdef _Py_DEC_REFTOTAL +# define GREENLET_Py_DEC_REFTOTAL _Py_DEC_REFTOTAL +#else /* _Py_DEC_REFTOTAL macro has been removed from Python 3.9 by: https://github.com/python/cpython/commit/49932fec62c616ec88da52642339d83ae719e924 @@ -81,12 +83,12 @@ Greenlet won't compile on anything older than Python 3.11 alpha 4 (see */ # ifdef Py_REF_DEBUG # if GREENLET_PY312 -# define _Py_DEC_REFTOTAL +# define GREENLET_Py_DEC_REFTOTAL # else -# define _Py_DEC_REFTOTAL _Py_RefTotal-- +# define GREENLET_Py_DEC_REFTOTAL _Py_RefTotal-- # endif # else -# define _Py_DEC_REFTOTAL +# define GREENLET_Py_DEC_REFTOTAL # endif #endif // Define these flags like Cython does if we're on an old version.