From f8607789d602fedba8fa8a03e0285c9f04f1dfa0 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 6 Jan 2020 17:53:25 +0100 Subject: [PATCH 1/2] Py_DECREF: only pass filename if Py_REF_DEBUG is defined Filename and line numbers are not needed when Py_REF_DEBUG are not defined. The static inline _Py_DECREF() function was introduced by commit 2aaf0c12041bcaadd7f2cc5a54450eefd7a6ff12. --- Include/object.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Include/object.h b/Include/object.h index a9d434b5108068..5e3e28c4f5fd15 100644 --- a/Include/object.h +++ b/Include/object.h @@ -461,8 +461,11 @@ static inline void _Py_INCREF(PyObject *op) #define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op)) -static inline void _Py_DECREF(const char *filename, int lineno, - PyObject *op) +static inline void _Py_DECREF( +#ifdef Py_REF_DEBUG + const char *filename, int lineno, +#endif + PyObject *op) { (void)filename; /* may be unused, shut up -Wunused-parameter */ (void)lineno; /* may be unused, shut up -Wunused-parameter */ @@ -479,7 +482,11 @@ static inline void _Py_DECREF(const char *filename, int lineno, } } -#define Py_DECREF(op) _Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op)) +#ifdef Py_REF_DEBUG +# define Py_DECREF(op) _Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op)) +#else +# define Py_DECREF(op) _Py_DECREF(_PyObject_CAST(op)) +#endif /* Safely decref `op` and set `op` to NULL, especially useful in tp_clear From bada3b992b83532d5b51c94e4184fdbdfc599455 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 6 Jan 2020 22:50:13 +0100 Subject: [PATCH 2/2] Fix compilation in release mode --- Include/object.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Include/object.h b/Include/object.h index 5e3e28c4f5fd15..7a5f57357b75f3 100644 --- a/Include/object.h +++ b/Include/object.h @@ -467,8 +467,6 @@ static inline void _Py_DECREF( #endif PyObject *op) { - (void)filename; /* may be unused, shut up -Wunused-parameter */ - (void)lineno; /* may be unused, shut up -Wunused-parameter */ _Py_DEC_REFTOTAL; if (--op->ob_refcnt != 0) { #ifdef Py_REF_DEBUG