From 3f974b378c3000ad1890ed170e2b029a4f73e7d9 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Tue, 30 May 2023 20:32:17 +0100 Subject: [PATCH 1/4] gh-105111: remove deprecated macros Py_TRASHCAN_SAFE_BEGIN and Py_TRASHCAN_SAFE_END --- Doc/whatsnew/3.13.rst | 33 +++++++++++++++++++ Include/cpython/object.h | 13 -------- ...-05-30-20-30-57.gh-issue-105111.atn0_6.rst | 3 ++ 3 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 8c81ac76a56b46..620b75b45b2633 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -270,6 +270,10 @@ Removed third-party Tix library which the module wrapped is unmaintained. (Contributed by Zachary Ware in :gh:`75552`.) +* Remove the old trashcan macros (``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``). + are now deprecated. They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` + and ``Py_TRASHCAN_END``. The new macros were added in Python 3.8 and the old macros + were deprecated in Python 3.11. (Contributed by Irit Katriel in :gh:`105111`.) Porting to Python 3.13 @@ -278,6 +282,35 @@ Porting to Python 3.13 This section lists previously described changes and other bugfixes that may require changes to your code. +* The old trashcan macros (``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``) + were removed. They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` + and ``Py_TRASHCAN_END``. + + A tp_dealloc function that has the old macros, such as:: + + static void + mytype_dealloc(mytype *p) + { + PyObject_GC_UnTrack(p); + Py_TRASHCAN_SAFE_BEGIN(p); + ... + Py_TRASHCAN_SAFE_END + } + + should migrate to the new macros as follows:: + + static void + mytype_dealloc(mytype *p) + { + PyObject_GC_UnTrack(p); + Py_TRASHCAN_BEGIN(p, mytype_dealloc) + ... + Py_TRASHCAN_END + } + + Note that ``Py_TRASHCAN_BEGIN`` has a second argument which + should be the deallocation function it is in. + Build Changes ============= diff --git a/Include/cpython/object.h b/Include/cpython/object.h index d8eff691039d24..7d69231aaa3119 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -539,19 +539,6 @@ PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc); Py_TRASHCAN_BEGIN_CONDITION((op), \ _PyTrash_cond(_PyObject_CAST(op), (destructor)(dealloc))) -/* The following two macros, Py_TRASHCAN_SAFE_BEGIN and - * Py_TRASHCAN_SAFE_END, are deprecated since version 3.11 and - * will be removed in the future. - * Use Py_TRASHCAN_BEGIN and Py_TRASHCAN_END instead. - */ -Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro; -#define Py_TRASHCAN_SAFE_BEGIN(op) \ - do { \ - UsingDeprecatedTrashcanMacro cond=1; \ - Py_TRASHCAN_BEGIN_CONDITION((op), cond); -#define Py_TRASHCAN_SAFE_END(op) \ - Py_TRASHCAN_END; \ - } while(0); PyAPI_FUNC(void *) PyObject_GetItemData(PyObject *obj); diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst b/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst new file mode 100644 index 00000000000000..b9071ddbe614fa --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst @@ -0,0 +1,3 @@ +Remove the old trashcan macros +(``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``). They should be +replaced by the new ≈macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``. From 456e9de8e45d0f458dca8e5748e41afa20cb3ec8 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Wed, 31 May 2023 11:57:59 +0100 Subject: [PATCH 2/4] Apply suggestions from code review --- Doc/whatsnew/3.13.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index d9f6e5b9deedc9..9b3b543b5becbd 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -273,8 +273,8 @@ Removed third-party Tix library which the module wrapped is unmaintained. (Contributed by Zachary Ware in :gh:`75552`.) -* Remove the old trashcan macros (``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``). - are now deprecated. They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` +* Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and ``Py_TRASHCAN_SAFE_END``. +They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``. The new macros were added in Python 3.8 and the old macros were deprecated in Python 3.11. (Contributed by Irit Katriel in :gh:`105111`.) @@ -285,7 +285,7 @@ Porting to Python 3.13 This section lists previously described changes and other bugfixes that may require changes to your code. -* The old trashcan macros (``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``) +* The old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and ``Py_TRASHCAN_SAFE_END`` were removed. They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``. From e5fa30db11dd78ac40a67e79a9dbf9487d87e1af Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Wed, 31 May 2023 12:00:07 +0100 Subject: [PATCH 3/4] whitespace --- Doc/whatsnew/3.13.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 9b3b543b5becbd..99a534e52433be 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -273,10 +273,11 @@ Removed third-party Tix library which the module wrapped is unmaintained. (Contributed by Zachary Ware in :gh:`75552`.) -* Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and ``Py_TRASHCAN_SAFE_END``. -They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` - and ``Py_TRASHCAN_END``. The new macros were added in Python 3.8 and the old macros - were deprecated in Python 3.11. (Contributed by Irit Katriel in :gh:`105111`.) +* Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and + ``Py_TRASHCAN_SAFE_END``. They should be replaced by the new macros + ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``. The new macros were + added in Python 3.8 and the old macros were deprecated in Python 3.11.i + (Contributed by Irit Katriel in :gh:`105111`.) Porting to Python 3.13 From 84e4517c83e84fe34395401d98172adc29aac898 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Wed, 31 May 2023 13:08:58 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Victor Stinner --- Doc/whatsnew/3.13.rst | 2 +- .../2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 99a534e52433be..e0da2a9fd80c35 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -276,7 +276,7 @@ Removed * Remove the old trashcan macros ``Py_TRASHCAN_SAFE_BEGIN`` and ``Py_TRASHCAN_SAFE_END``. They should be replaced by the new macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``. The new macros were - added in Python 3.8 and the old macros were deprecated in Python 3.11.i + added in Python 3.8 and the old macros were deprecated in Python 3.11. (Contributed by Irit Katriel in :gh:`105111`.) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst b/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst index b9071ddbe614fa..7f9c5cc95680d8 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst @@ -1,3 +1,3 @@ Remove the old trashcan macros -(``Py_TRASHCAN_SAFE_BEGIN``/``Py_TRASHCAN_SAFE_END``). They should be -replaced by the new ≈macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``. +``Py_TRASHCAN_SAFE_BEGIN`` and ``Py_TRASHCAN_SAFE_END``. They should be +replaced by the new macros ``Py_TRASHCAN_BEGIN`` and ``Py_TRASHCAN_END``.