diff --git a/Include/object.h b/Include/object.h index c2fee85a2c38f6a..dc5b087db2f467b 100644 --- a/Include/object.h +++ b/Include/object.h @@ -585,20 +585,14 @@ decision that's up to the implementer of each new type so if you want, you can count such references to the type object.) */ -#ifdef Py_REF_DEBUG -# if defined(Py_LIMITED_API) && Py_LIMITED_API+0 < 0x030A0000 -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 +#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API) +PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno, + PyObject *op); 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() # define _Py_DEC_REFTOTAL() _Py_DecRefTotal_DO_NOT_USE_THIS() -# endif -PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno, - PyObject *op); -#endif /* Py_REF_DEBUG */ +#endif // Py_REF_DEBUG && !Py_LIMITED_API PyAPI_FUNC(void) _Py_Dealloc(PyObject *); @@ -616,8 +610,8 @@ PyAPI_FUNC(void) _Py_DecRef(PyObject *); static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) { -#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000 - // Stable ABI for Python 3.10 built in debug mode. +#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) + // Stable ABI for Python built in debug mode _Py_IncRef(op); #else // Non-limited C API and limited C API for Python 3.9 and older access @@ -647,8 +641,8 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op) # define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op)) #endif -#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000 -// Stable ABI for limited C API version 3.10 of Python debug build +#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) +// Stable ABI for Python built in debug mode static inline void Py_DECREF(PyObject *op) { _Py_DecRef(op); } diff --git a/Lib/test/test_stable_abi_ctypes.py b/Lib/test/test_stable_abi_ctypes.py index 60ad3603ae92233..8cad71c7c34545c 100644 --- a/Lib/test/test_stable_abi_ctypes.py +++ b/Lib/test/test_stable_abi_ctypes.py @@ -1,5 +1,4 @@ - -# Generated by Tools/scripts/stable_abi.py +# Generated by Tools/build/stable_abi.py """Test that all symbols of the Stable ABI are accessible using ctypes """ @@ -918,8 +917,6 @@ 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 4d833878734d080..f9100054175fc1e 100644 --- a/Misc/stable_abi.toml +++ b/Misc/stable_abi.toml @@ -2428,12 +2428,3 @@ 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/Modules/_testcapi_feature_macros.inc b/Modules/_testcapi_feature_macros.inc index b1763b57d913c2e..a076e7149800743 100644 --- a/Modules/_testcapi_feature_macros.inc +++ b/Modules/_testcapi_feature_macros.inc @@ -1,4 +1,4 @@ -// Generated by Tools/scripts/stable_abi.py +// Generated by Tools/build/stable_abi.py // Add an entry in dict `result` for each Stable ABI feature macro. diff --git a/PC/python3dll.c b/PC/python3dll.c index f2c0d9dee883d99..7e848abccfd1fa6 100755 --- a/PC/python3dll.c +++ b/PC/python3dll.c @@ -18,9 +18,7 @@ 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) diff --git a/Tools/build/stable_abi.py b/Tools/build/stable_abi.py index 42b2dd92307bbf0..2224dd17214af4f 100644 --- a/Tools/build/stable_abi.py +++ b/Tools/build/stable_abi.py @@ -267,8 +267,8 @@ def gen_doc_annotations(manifest, args, outfile): def gen_ctypes_test(manifest, args, outfile): """Generate/check the ctypes-based test for exported symbols""" write = partial(print, file=outfile) - write(textwrap.dedent(''' - # Generated by Tools/scripts/stable_abi.py + write(textwrap.dedent(f'''\ + # Generated by {SCRIPT_NAME} """Test that all symbols of the Stable ABI are accessible using ctypes """ @@ -341,7 +341,7 @@ def test_windows_feature_macros(self): def gen_testcapi_feature_macros(manifest, args, outfile): """Generate/check the stable ABI list for documentation annotations""" write = partial(print, file=outfile) - write('// Generated by Tools/scripts/stable_abi.py') + write(f'// Generated by {SCRIPT_NAME}') write() write('// Add an entry in dict `result` for each Stable ABI feature macro.') write()