Skip to content
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
apply victor's comment
  • Loading branch information
shihai1991 committed Nov 13, 2020
commit a0c82d7bf4fd53cca29556c3e293e2dc73a1a144
5 changes: 0 additions & 5 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,6 @@ New Features
* The :c:func:`PyType_GetSlot` function can accept static types.
(Contributed by Hai Shi and Petr Viktorin in :issue:`41073`.)

* The ``Py_TRASHCAN_BEGIN`` macro no longer accesses PyTypeObject attributes,
but now can get the condition by calling the new private
:c:func:`_PyTrash_cond()` function which hides implementation details.
(Contributed by Hai Shi in :issue:`40170`.)


Porting to Python 3.10
----------------------
Expand Down
6 changes: 3 additions & 3 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,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 macros below. */
PyAPI_FUNC(int) _PyTrash_cond(void *op_raw, void *dealloc);
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, void *dealloc);

#define PyTrash_UNWIND_LEVEL 50

Expand All @@ -539,7 +539,7 @@ PyAPI_FUNC(int) _PyTrash_cond(void *op_raw, void *dealloc);
} while (0);

#define Py_TRASHCAN_BEGIN(op, dealloc) \
Py_TRASHCAN_BEGIN_CONDITION(op, _PyTrash_cond(op, dealloc));
Py_TRASHCAN_BEGIN_CONDITION(op, _PyTrash_cond(_PyObject_CAST(op), dealloc))

/* For backwards compatibility, these macros enable the trashcan
* unconditionally */
Expand Down
3 changes: 1 addition & 2 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -2135,9 +2135,8 @@ _PyTrash_end(PyThreadState *tstate)


int

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add comment explaining that it is used by the Py_TRASHCAN_BEGIN macro.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Got it, updated.

_PyTrash_cond(void *op_raw, void *dealloc)
_PyTrash_cond(PyObject *op, void *dealloc)
Comment thread
shihai1991 marked this conversation as resolved.
Outdated
{
PyObject *op = _PyObject_CAST(op_raw);
PyTypeObject *tp = Py_TYPE(op);
return tp->tp_dealloc == (destructor)dealloc;
}
Expand Down