aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-11-25 06:03:31 +0800
committerGitHub <noreply@github.com>2020-11-24 23:03:31 +0100
commited1a5a5baca8f61e9a99c5be3adc16b1801514fe (patch)
treef3db72407b31e7a94b025ab181455df83d770780 /Include
parentbpo-42392: Remove loop parameter form asyncio locks and Queue (#23420) (diff)
downloadcpython-ed1a5a5baca8f61e9a99c5be3adc16b1801514fe.tar.gz
cpython-ed1a5a5baca8f61e9a99c5be3adc16b1801514fe.tar.bz2
cpython-ed1a5a5baca8f61e9a99c5be3adc16b1801514fe.zip
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.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/object.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 43b0be3755..19c066b0ab 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -516,6 +516,8 @@ struct _ts;
/* Python 3.9 private API, invoked by the macros below. */
PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
+/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
+PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
#define PyTrash_UNWIND_LEVEL 50
@@ -539,7 +541,7 @@ PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
#define Py_TRASHCAN_BEGIN(op, dealloc) \
Py_TRASHCAN_BEGIN_CONDITION(op, \
- Py_TYPE(op)->tp_dealloc == (destructor)(dealloc))
+ _PyTrash_cond(_PyObject_CAST(op), (destructor)dealloc))
/* For backwards compatibility, these macros enable the trashcan
* unconditionally */