]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105111: remove deprecated macros Py_TRASHCAN_SAFE_BEGIN and Py_TRASHCAN_SAFE_END...
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Wed, 31 May 2023 14:44:11 +0000 (15:44 +0100)
committerGitHub <noreply@github.com>
Wed, 31 May 2023 14:44:11 +0000 (15:44 +0100)
Doc/whatsnew/3.13.rst
Include/cpython/object.h
Misc/NEWS.d/next/Core and Builtins/2023-05-30-20-30-57.gh-issue-105111.atn0_6.rst [new file with mode: 0644]

index 59c7f78b38022113cb223699a5faf0da38aa3490..441b3ab3f51f1a9b9b29193cc5655dcbd39148c4 100644 (file)
@@ -286,6 +286,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`.)
 
 
 Porting to Python 3.13
@@ -294,6 +299,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`` and ``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
 =============
index d8eff691039d2400f00e12c3252572aef95db954..7d69231aaa311972829586c9318a4e9e6af7122e 100644 (file)
@@ -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 (file)
index 0000000..7f9c5cc
--- /dev/null
@@ -0,0 +1,3 @@
+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``.