summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-01-08 21:03:45 +0100
committerGitHub <noreply@github.com>2020-01-08 21:03:45 +0100
commitf3a0a6bbccfcd9d18afe5575617aefaee9fa37a5 (patch)
tree79a1f4581da2317072a3db0329397626ecd2f472
parent5907e61a8d4da6d0f11bf1062d6d17484560a15e (diff)
downloadcpython-git-f3a0a6bbccfcd9d18afe5575617aefaee9fa37a5.tar.gz
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 2aaf0c12041bcaadd7f2cc5a54450eefd7a6ff12.
-rw-r--r--Include/object.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/Include/object.h b/Include/object.h
index a9d434b510..7a5f57357b 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -461,11 +461,12 @@ 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 */
_Py_DEC_REFTOTAL;
if (--op->ob_refcnt != 0) {
#ifdef Py_REF_DEBUG
@@ -479,7 +480,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