mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-39947: Hide implementation detail of trashcan macros (GH-18971)
Py_TRASHCAN_BEGIN_CONDITION and Py_TRASHCAN_END macro no longer access PyThreadState attributes, but call new private _PyTrash_begin() and _PyTrash_end() functions which hide implementation details.
This commit is contained in:
parent
309d7cc5df
commit
38965ec541
3 changed files with 45 additions and 15 deletions
|
@ -2116,6 +2116,30 @@ _PyTrash_thread_destroy_chain(void)
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
_PyTrash_begin(PyThreadState *tstate, PyObject *op)
|
||||
{
|
||||
if (tstate->trash_delete_nesting >= PyTrash_UNWIND_LEVEL) {
|
||||
/* Store the object (to be deallocated later) and jump past
|
||||
* Py_TRASHCAN_END, skipping the body of the deallocator */
|
||||
_PyTrash_thread_deposit_object(op);
|
||||
return 1;
|
||||
}
|
||||
++tstate->trash_delete_nesting;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyTrash_end(PyThreadState *tstate)
|
||||
{
|
||||
--tstate->trash_delete_nesting;
|
||||
if (tstate->trash_delete_later && tstate->trash_delete_nesting <= 0) {
|
||||
_PyTrash_thread_destroy_chain();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _Py_NO_RETURN
|
||||
_PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
|
||||
const char *file, int line, const char *function)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue