Skip to content

Py_DECREF: only pass filename if Py_REF_DEBUG is defined #17870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These suppressions shouldn't be necessary anymore, but if they are, they should be conditional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suppression are needed with the current code, since filename & fileno are not used for a release build. It's the purpose of my change: don't pass them if we don't need them ;-)

(void)lineno; /* may be unused, shut up -Wunused-parameter */
Expand All @@ -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
Expand Down