From 301eb7e607be6ea15c7a1e792f1cb927ba423932 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 29 Aug 2023 04:05:11 +0200 Subject: [PATCH] gh-106320: Remove _PyAnextAwaitable_Type from the public C API (#108597) It's not needed to declare it in Include/iterobject.h: just use "extern" where it's used (only in object.c). --- Include/iterobject.h | 3 --- Objects/object.c | 9 +++++---- Tools/c-analyzer/c_parser/preprocessor/gcc.py | 1 - Tools/c-analyzer/cpython/globals-to-fix.tsv | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Include/iterobject.h b/Include/iterobject.h index fff30f7176f..e69d09719bb 100644 --- a/Include/iterobject.h +++ b/Include/iterobject.h @@ -7,9 +7,6 @@ extern "C" { PyAPI_DATA(PyTypeObject) PySeqIter_Type; PyAPI_DATA(PyTypeObject) PyCallIter_Type; -#ifdef Py_BUILD_CORE -extern PyTypeObject _PyAnextAwaitable_Type; -#endif #define PySeqIter_Check(op) Py_IS_TYPE((op), &PySeqIter_Type) diff --git a/Objects/object.c b/Objects/object.c index 02e26110209..0d88421bf0f 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2049,11 +2049,12 @@ _PyObject_InitState(PyInterpreterState *interp) } -extern PyTypeObject _Py_GenericAliasIterType; -extern PyTypeObject _PyMemoryIter_Type; -extern PyTypeObject _PyLineIterator; -extern PyTypeObject _PyPositionsIterator; +extern PyTypeObject _PyAnextAwaitable_Type; extern PyTypeObject _PyLegacyEventHandler_Type; +extern PyTypeObject _PyLineIterator; +extern PyTypeObject _PyMemoryIter_Type; +extern PyTypeObject _PyPositionsIterator; +extern PyTypeObject _Py_GenericAliasIterType; static PyTypeObject* static_types[] = { // The two most important base types: must be initialized first and diff --git a/Tools/c-analyzer/c_parser/preprocessor/gcc.py b/Tools/c-analyzer/c_parser/preprocessor/gcc.py index 55cc2d37e1e..18d1b1a5d0a 100644 --- a/Tools/c-analyzer/c_parser/preprocessor/gcc.py +++ b/Tools/c-analyzer/c_parser/preprocessor/gcc.py @@ -69,7 +69,6 @@ def preprocess(filename, cwd = os.path.abspath(cwd or '.') filename = _normpath(filename, cwd) - print(filename) postargs = POST_ARGS if os.path.basename(filename) not in USE_LIMITED_C_API: postargs += ('-DPy_BUILD_CORE=1',) diff --git a/Tools/c-analyzer/cpython/globals-to-fix.tsv b/Tools/c-analyzer/cpython/globals-to-fix.tsv index 58f9c8e8a3e..bb85fba895b 100644 --- a/Tools/c-analyzer/cpython/globals-to-fix.tsv +++ b/Tools/c-analyzer/cpython/globals-to-fix.tsv @@ -57,6 +57,7 @@ Objects/genobject.c - _PyCoroWrapper_Type - Objects/interpreteridobject.c - PyInterpreterID_Type - Objects/iterobject.c - PyCallIter_Type - Objects/iterobject.c - PySeqIter_Type - +Objects/iterobject.c - _PyAnextAwaitable_Type - Objects/listobject.c - PyListIter_Type - Objects/listobject.c - PyListRevIter_Type - Objects/listobject.c - PyList_Type - @@ -70,6 +71,7 @@ Objects/moduleobject.c - PyModule_Type - Objects/namespaceobject.c - _PyNamespace_Type - Objects/object.c - _PyNone_Type - Objects/object.c - _PyNotImplemented_Type - +Objects/object.c - _PyAnextAwaitable_Type - Objects/odictobject.c - PyODictItems_Type - Objects/odictobject.c - PyODictIter_Type - Objects/odictobject.c - PyODictKeys_Type - @@ -113,8 +115,6 @@ Objects/codeobject.c - _PyLineIterator - Objects/codeobject.c - _PyPositionsIterator - Objects/genericaliasobject.c - _Py_GenericAliasIterType - # Not in a .h file: -Objects/iterobject.c - _PyAnextAwaitable_Type - -# Not in a .h file: Objects/memoryobject.c - _PyMemoryIter_Type - Objects/unicodeobject.c - _PyUnicodeASCIIIter_Type - Objects/unionobject.c - _PyUnion_Type -