Skip to content

Commit e3e2953

Browse files
authored
Merge pull request #459 from mgorny/py314-debug-build-failure
Redefine `_Py_DEC_REFTOTAL` as a private macro to fix py3.14 debug build
2 parents bdb5f44 + ca40117 commit e3e2953

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/greenlet/PyGreenlet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ _green_dealloc_kill_started_non_main_greenlet(BorrowedGreenlet self)
249249

250250
PyObject_GC_Track((PyObject*)self);
251251

252-
_Py_DEC_REFTOTAL;
252+
GREENLET_Py_DEC_REFTOTAL;
253253
#ifdef COUNT_ALLOCS
254254
--Py_TYPE(self)->tp_frees;
255255
--Py_TYPE(self)->tp_allocs;

src/greenlet/greenlet_cpython_compat.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,22 @@ Greenlet won't compile on anything older than Python 3.11 alpha 4 (see
7373
# define Py_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
7474
#endif
7575

76-
#ifndef _Py_DEC_REFTOTAL
76+
#ifdef _Py_DEC_REFTOTAL
77+
# define GREENLET_Py_DEC_REFTOTAL _Py_DEC_REFTOTAL
78+
#else
7779
/* _Py_DEC_REFTOTAL macro has been removed from Python 3.9 by:
7880
https://github.com/python/cpython/commit/49932fec62c616ec88da52642339d83ae719e924
7981
8082
The symbol we use to replace it was removed by at least 3.12.
8183
*/
8284
# ifdef Py_REF_DEBUG
8385
# if GREENLET_PY312
84-
# define _Py_DEC_REFTOTAL
86+
# define GREENLET_Py_DEC_REFTOTAL
8587
# else
86-
# define _Py_DEC_REFTOTAL _Py_RefTotal--
88+
# define GREENLET_Py_DEC_REFTOTAL _Py_RefTotal--
8789
# endif
8890
# else
89-
# define _Py_DEC_REFTOTAL
91+
# define GREENLET_Py_DEC_REFTOTAL
9092
# endif
9193
#endif
9294
// Define these flags like Cython does if we're on an old version.

0 commit comments

Comments
 (0)