From 4cabc8c07a12aed8fcf07d18007ca7109f4e5502 Mon Sep 17 00:00:00 2001 From: ruang Date: Mon, 14 Oct 2024 19:42:34 +0800 Subject: [PATCH 1/3] Remove Py_TPFLAGS_HAVE_FINALIZE macro --- Include/object.h | 1 - Modules/_testcapi/heaptype.c | 2 +- Modules/_testmultiphase.c | 2 +- Modules/posixmodule.c | 3 +-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Include/object.h b/Include/object.h index abfdb6ce24df21..4533004f8976ba 100644 --- a/Include/object.h +++ b/Include/object.h @@ -595,7 +595,6 @@ given type object has a specified feature. * Note that older extensions using the stable ABI set these flags, * so the bits must not be repurposed. */ -#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0) #define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) diff --git a/Modules/_testcapi/heaptype.c b/Modules/_testcapi/heaptype.c index b45b890b88d81f..c2a115d5b21bd2 100644 --- a/Modules/_testcapi/heaptype.c +++ b/Modules/_testcapi/heaptype.c @@ -710,7 +710,7 @@ static PyType_Spec HeapCTypeSubclassWithFinalizer_spec = { "_testcapi.HeapCTypeSubclassWithFinalizer", sizeof(HeapCTypeSubclassObject), 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_FINALIZE, + Py_TPFLAGS_DEFAULT, HeapCTypeSubclassWithFinalizer_slots }; diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index 886b260aceb20d..8fed7e748af494 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -289,7 +289,7 @@ static PyType_Spec StateAccessType_spec = { "_testimportexec.StateAccessType", sizeof(StateAccessTypeObject), 0, - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_FINALIZE | Py_TPFLAGS_BASETYPE, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, StateAccessType_Type_slots }; diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f24ab81cbcb77b..6bc1503e8a3028 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -16325,8 +16325,7 @@ static PyType_Spec ScandirIteratorType_spec = { 0, // bpo-40549: Py_TPFLAGS_BASETYPE should not be used, since // PyType_GetModule(Py_TYPE(self)) doesn't work on a subclass instance. - (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_FINALIZE - | Py_TPFLAGS_DISALLOW_INSTANTIATION), + (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION), ScandirIteratorType_slots }; From fafa378289eacf05ff33bbc669f2212f9ca4c5e1 Mon Sep 17 00:00:00 2001 From: ruang Date: Mon, 14 Oct 2024 19:48:19 +0800 Subject: [PATCH 2/3] Add NEWS --- .../next/C_API/2024-10-14-19-48-07.gh-issue-125448._fDzec.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/C_API/2024-10-14-19-48-07.gh-issue-125448._fDzec.rst diff --git a/Misc/NEWS.d/next/C_API/2024-10-14-19-48-07.gh-issue-125448._fDzec.rst b/Misc/NEWS.d/next/C_API/2024-10-14-19-48-07.gh-issue-125448._fDzec.rst new file mode 100644 index 00000000000000..c91afa4ac781d9 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2024-10-14-19-48-07.gh-issue-125448._fDzec.rst @@ -0,0 +1 @@ +Remove :c:macro:`Py_TPFLAGS_HAVE_FINALIZE` macro. From 638ac0e1fe9d2f4a1629326da1e270328f1b1bcd Mon Sep 17 00:00:00 2001 From: ruang Date: Mon, 14 Oct 2024 19:56:38 +0800 Subject: [PATCH 3/3] Remove Py_TPFLAGS_HAVE_FINALIZE related documentation --- Doc/c-api/typeobj.rst | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index b7b1418df513c6..7e282f9c5c8d92 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -1200,20 +1200,6 @@ and :c:data:`PyType_Type` effectively act as defaults.) set appropriately, or the code that interacts with such types will behave differently depending on what kind of check is used. - - .. c:macro:: Py_TPFLAGS_HAVE_FINALIZE - - This bit is set when the :c:member:`~PyTypeObject.tp_finalize` slot is present in the - type structure. - - .. versionadded:: 3.4 - - .. deprecated:: 3.8 - This flag isn't necessary anymore, as the interpreter assumes the - :c:member:`~PyTypeObject.tp_finalize` slot is always present in the - type structure. - - .. c:macro:: Py_TPFLAGS_HAVE_VECTORCALL This bit is set when the class implements @@ -2126,12 +2112,6 @@ and :c:data:`PyType_Type` effectively act as defaults.) .. versionadded:: 3.4 - .. versionchanged:: 3.8 - - Before version 3.8 it was necessary to set the - :c:macro:`Py_TPFLAGS_HAVE_FINALIZE` flags bit in order for this field to be - used. This is no longer required. - .. seealso:: "Safe object finalization" (:pep:`442`)