Skip to content

Commit f3a0a6b

Browse files
authored
Py_DECREF: only pass filename if Py_REF_DEBUG is defined (GH-17870)
Filename and line numbers are not needed when Py_REF_DEBUG are not defined. The static inline _Py_DECREF() function was introduced by commit 2aaf0c1.
1 parent 5907e61 commit f3a0a6b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Include/object.h

+10-5
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ static inline void _Py_INCREF(PyObject *op)
461461

462462
#define Py_INCREF(op) _Py_INCREF(_PyObject_CAST(op))
463463

464-
static inline void _Py_DECREF(const char *filename, int lineno,
465-
PyObject *op)
464+
static inline void _Py_DECREF(
465+
#ifdef Py_REF_DEBUG
466+
const char *filename, int lineno,
467+
#endif
468+
PyObject *op)
466469
{
467-
(void)filename; /* may be unused, shut up -Wunused-parameter */
468-
(void)lineno; /* may be unused, shut up -Wunused-parameter */
469470
_Py_DEC_REFTOTAL;
470471
if (--op->ob_refcnt != 0) {
471472
#ifdef Py_REF_DEBUG
@@ -479,7 +480,11 @@ static inline void _Py_DECREF(const char *filename, int lineno,
479480
}
480481
}
481482

482-
#define Py_DECREF(op) _Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
483+
#ifdef Py_REF_DEBUG
484+
# define Py_DECREF(op) _Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
485+
#else
486+
# define Py_DECREF(op) _Py_DECREF(_PyObject_CAST(op))
487+
#endif
483488

484489

485490
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear

0 commit comments

Comments
 (0)