bpo-40170: Hide impl detail of Py_TRASHCAN_BEGIN macro (GH-23235)

The Py_TRASHCAN_BEGIN macro no longer accesses PyTypeObject attributes,
but now can get the condition by calling the new private
_PyTrash_cond() function which hides implementation details.
This commit is contained in:
Hai Shi 2020-11-25 06:03:31 +08:00 committed by GitHub
parent 0ec34cab9d
commit ed1a5a5bac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -2134,6 +2134,15 @@ _PyTrash_end(PyThreadState *tstate)
}
/* bpo-40170: It's only be used in Py_TRASHCAN_BEGIN macro to hide
implementation details. */
int
_PyTrash_cond(PyObject *op, destructor dealloc)
{
return Py_TYPE(op)->tp_dealloc == dealloc;
}
void _Py_NO_RETURN
_PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
const char *file, int line, const char *function)