From f87c6d189418850ac9c2e5f9cb08531cf004f704 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 31 May 2023 15:17:24 -0600 Subject: [PATCH] [3.12] gh-102304: Fix 2 New Stable ABI Functions (gh-104762) (gh-105123) --- Include/object.h | 2 +- Lib/test/test_stable_abi_ctypes.py | 2 ++ Misc/stable_abi.toml | 9 +++++++++ PC/python3dll.c | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Include/object.h b/Include/object.h index 81aeb2d8bd5a69..c2fee85a2c38f6 100644 --- a/Include/object.h +++ b/Include/object.h @@ -590,7 +590,7 @@ you can count such references to the type object.) extern Py_ssize_t _Py_RefTotal; # define _Py_INC_REFTOTAL() _Py_RefTotal++ # define _Py_DEC_REFTOTAL() _Py_RefTotal-- -# elif !defined(Py_LIMITED_API) || Py_LIMITED_API+0 > 0x030C0000 +# elif !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000 PyAPI_FUNC(void) _Py_IncRefTotal_DO_NOT_USE_THIS(void); PyAPI_FUNC(void) _Py_DecRefTotal_DO_NOT_USE_THIS(void); # define _Py_INC_REFTOTAL() _Py_IncRefTotal_DO_NOT_USE_THIS() diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py index 4ca39d85e5460c..60ad3603ae9223 100644 --- a/Lib/test/test_stable_abi_ctypes.py +++ b/Lib/test/test_stable_abi_ctypes.py @@ -918,6 +918,8 @@ def test_windows_feature_macros(self): ) if feature_macros['Py_REF_DEBUG']: SYMBOL_NAMES += ( + '_Py_DecRefTotal_DO_NOT_USE_THIS', + '_Py_IncRefTotal_DO_NOT_USE_THIS', '_Py_NegativeRefcount', '_Py_RefTotal', ) diff --git a/Misc/stable_abi.toml b/Misc/stable_abi.toml index 48299e9b35ff97..1db98483f09f77 100644 --- a/Misc/stable_abi.toml +++ b/Misc/stable_abi.toml @@ -2406,3 +2406,12 @@ added = '3.12' [const.Py_TPFLAGS_ITEMS_AT_END] added = '3.12' + +[function._Py_IncRefTotal_DO_NOT_USE_THIS] + added = '3.12' + ifdef = 'Py_REF_DEBUG' + abi_only = true +[function._Py_DecRefTotal_DO_NOT_USE_THIS] + added = '3.12' + ifdef = 'Py_REF_DEBUG' + abi_only = true diff --git a/PC/python3dll.c b/PC/python3dll.c index 7e848abccfd1fa..f2c0d9dee883d9 100755 --- a/PC/python3dll.c +++ b/PC/python3dll.c @@ -18,7 +18,9 @@ EXPORT_FUNC(_Py_BuildValue_SizeT) EXPORT_FUNC(_Py_CheckRecursiveCall) EXPORT_FUNC(_Py_Dealloc) EXPORT_FUNC(_Py_DecRef) +EXPORT_FUNC(_Py_DecRefTotal_DO_NOT_USE_THIS) EXPORT_FUNC(_Py_IncRef) +EXPORT_FUNC(_Py_IncRefTotal_DO_NOT_USE_THIS) EXPORT_FUNC(_Py_NegativeRefcount) EXPORT_FUNC(_Py_VaBuildValue_SizeT) EXPORT_FUNC(_PyArg_Parse_SizeT)