diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index 734cf1572fc..2e952281865 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -572,7 +572,8 @@ Porting to Python 3.11 header provides functions like ``printf()`` and ``fopen()``. (Contributed by Victor Stinner in :issue:`45434`.) -* The non-limited API files ``cellobject.h`` and ``funcobject.h`` have been +* The non-limited API files ``cellobject.h``, ``classobject.h``, ``context.h``, + ``funcobject.h``, ``genobject.h`` and ``longintrepr.h`` have been moved to the ``Include/cpython`` directory. These files must not be included directly, as they are already included in ``Python.h``: :ref:`Include Files `. If they have been included directly, consider including diff --git a/Include/Python.h b/Include/Python.h index 89f60fe5c9f..bc8d4f9b548 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -46,7 +46,7 @@ #include "bytesobject.h" #include "unicodeobject.h" #include "longobject.h" -#include "longintrepr.h" +#include "cpython/longintrepr.h" #include "boolobject.h" #include "floatobject.h" #include "complexobject.h" @@ -61,7 +61,7 @@ #include "methodobject.h" #include "moduleobject.h" #include "cpython/funcobject.h" -#include "classobject.h" +#include "cpython/classobject.h" #include "fileobject.h" #include "pycapsule.h" #include "code.h" @@ -70,7 +70,8 @@ #include "sliceobject.h" #include "cpython/cellobject.h" #include "iterobject.h" -#include "genobject.h" +#include "pystate.h" +#include "cpython/genobject.h" #include "descrobject.h" #include "genericaliasobject.h" #include "warnings.h" @@ -83,8 +84,7 @@ #include "pyerrors.h" #include "cpython/initconfig.h" #include "pythread.h" -#include "pystate.h" -#include "context.h" +#include "cpython/context.h" #include "modsupport.h" #include "compile.h" #include "pythonrun.h" diff --git a/Include/classobject.h b/Include/cpython/classobject.h similarity index 96% rename from Include/classobject.h rename to Include/cpython/classobject.h index 1952f673b7d..80df8842eb4 100644 --- a/Include/classobject.h +++ b/Include/cpython/classobject.h @@ -53,5 +53,5 @@ PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); #ifdef __cplusplus } #endif -#endif /* !Py_CLASSOBJECT_H */ -#endif /* Py_LIMITED_API */ +#endif // !Py_CLASSOBJECT_H +#endif // !Py_LIMITED_API diff --git a/Include/context.h b/Include/cpython/context.h similarity index 99% rename from Include/context.h rename to Include/cpython/context.h index 4e5007089dd..4db079f7633 100644 --- a/Include/context.h +++ b/Include/cpython/context.h @@ -1,12 +1,10 @@ +#ifndef Py_LIMITED_API #ifndef Py_CONTEXT_H #define Py_CONTEXT_H #ifdef __cplusplus extern "C" { #endif -#ifndef Py_LIMITED_API - - PyAPI_DATA(PyTypeObject) PyContext_Type; typedef struct _pycontextobject PyContext; @@ -73,9 +71,8 @@ PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token); PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void); -#endif /* !Py_LIMITED_API */ - #ifdef __cplusplus } #endif #endif /* !Py_CONTEXT_H */ +#endif /* !Py_LIMITED_API */ diff --git a/Include/genobject.h b/Include/cpython/genobject.h similarity index 93% rename from Include/genobject.h rename to Include/cpython/genobject.h index 55a8b34afd6..8f87cf5fff7 100644 --- a/Include/genobject.h +++ b/Include/cpython/genobject.h @@ -1,4 +1,3 @@ - /* Generator object interface */ #ifndef Py_LIMITED_API @@ -8,8 +7,7 @@ extern "C" { #endif -#include "pystate.h" /* _PyErr_StackItem */ -#include "abstract.h" /* PySendResult */ +/* --- Generators --------------------------------------------------------- */ /* _PyGenObject_HEAD defines the initial segment of generator and coroutine objects. */ @@ -45,7 +43,9 @@ PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); PyObject *_PyGen_yf(PyGenObject *); PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self); -#ifndef Py_LIMITED_API + +/* --- PyCoroObject ------------------------------------------------------- */ + typedef struct { _PyGenObject_HEAD(cr) PyObject *cr_origin; @@ -59,7 +59,8 @@ PyObject *_PyCoro_GetAwaitableIter(PyObject *o); PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *, PyObject *name, PyObject *qualname); -/* Asynchronous Generators */ + +/* --- Asynchronous Generators -------------------------------------------- */ typedef struct { _PyGenObject_HEAD(ag) @@ -89,7 +90,6 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *, PyObject *_PyAsyncGenValueWrapperNew(PyObject *); -#endif #undef _PyGenObject_HEAD diff --git a/Include/longintrepr.h b/Include/cpython/longintrepr.h similarity index 100% rename from Include/longintrepr.h rename to Include/cpython/longintrepr.h diff --git a/Makefile.pre.in b/Makefile.pre.in index 32bbab068f7..a81161e147d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1128,12 +1128,10 @@ PYTHON_HEADERS= \ $(srcdir)/Include/bytearrayobject.h \ $(srcdir)/Include/bytesobject.h \ $(srcdir)/Include/ceval.h \ - $(srcdir)/Include/classobject.h \ $(srcdir)/Include/code.h \ $(srcdir)/Include/codecs.h \ $(srcdir)/Include/compile.h \ $(srcdir)/Include/complexobject.h \ - $(srcdir)/Include/context.h \ $(srcdir)/Include/descrobject.h \ $(srcdir)/Include/dictobject.h \ $(srcdir)/Include/dynamic_annotations.h \ @@ -1144,13 +1142,11 @@ PYTHON_HEADERS= \ $(srcdir)/Include/fileutils.h \ $(srcdir)/Include/floatobject.h \ $(srcdir)/Include/frameobject.h \ - $(srcdir)/Include/genobject.h \ $(srcdir)/Include/import.h \ $(srcdir)/Include/interpreteridobject.h \ $(srcdir)/Include/intrcheck.h \ $(srcdir)/Include/iterobject.h \ $(srcdir)/Include/listobject.h \ - $(srcdir)/Include/longintrepr.h \ $(srcdir)/Include/longobject.h \ $(srcdir)/Include/marshal.h \ $(srcdir)/Include/memoryobject.h \ @@ -1202,18 +1198,22 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/bytesobject.h \ $(srcdir)/Include/cpython/cellobject.h \ $(srcdir)/Include/cpython/ceval.h \ + $(srcdir)/Include/cpython/classobject.h \ $(srcdir)/Include/cpython/code.h \ $(srcdir)/Include/cpython/compile.h \ + $(srcdir)/Include/cpython/context.h \ $(srcdir)/Include/cpython/dictobject.h \ $(srcdir)/Include/cpython/fileobject.h \ $(srcdir)/Include/cpython/fileutils.h \ $(srcdir)/Include/cpython/floatobject.h \ $(srcdir)/Include/cpython/frameobject.h \ $(srcdir)/Include/cpython/funcobject.h \ + $(srcdir)/Include/cpython/genobject.h \ $(srcdir)/Include/cpython/import.h \ $(srcdir)/Include/cpython/initconfig.h \ $(srcdir)/Include/cpython/interpreteridobject.h \ $(srcdir)/Include/cpython/listobject.h \ + $(srcdir)/Include/cpython/longintrepr.h \ $(srcdir)/Include/cpython/methodobject.h \ $(srcdir)/Include/cpython/object.h \ $(srcdir)/Include/cpython/objimpl.h \ diff --git a/Misc/NEWS.d/next/C API/2021-10-15-00-11-51.bpo-35134.eX4zqy.rst b/Misc/NEWS.d/next/C API/2021-10-15-00-11-51.bpo-35134.eX4zqy.rst index 800f6e7f927..4ab10884a54 100644 --- a/Misc/NEWS.d/next/C API/2021-10-15-00-11-51.bpo-35134.eX4zqy.rst +++ b/Misc/NEWS.d/next/C API/2021-10-15-00-11-51.bpo-35134.eX4zqy.rst @@ -1,3 +1,4 @@ -Move ``cellobject.h`` and ``funcobject.h`` header files from ``Include/`` to +Move ``cellobject.h``, ``classobject.h``, ``context.h``, ``funcobject.h``, +``genobject.h`` and ``longintrepr.h`` header files from ``Include/`` to ``Include/cpython/``. C extensions should only include the main ```` header. Patch by Victor Stinner. diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index dd876f20036..237edd5191f 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -28,7 +28,6 @@ #include #include "pycore_pystate.h" // _PyThreadState_GET() -#include "longintrepr.h" #include "complexobject.h" #include "mpdecimal.h" diff --git a/Objects/abstract.c b/Objects/abstract.c index 0d6cefd3eb8..6f7b94600e2 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -10,7 +10,6 @@ #include "pycore_unionobject.h" // _PyUnion_Check() #include #include // offsetof() -#include "longintrepr.h" diff --git a/Objects/boolobject.c b/Objects/boolobject.c index c72243a160b..53f81926057 100644 --- a/Objects/boolobject.c +++ b/Objects/boolobject.c @@ -2,7 +2,6 @@ #include "Python.h" #include "pycore_pyerrors.h" // _Py_FatalRefcountError() -#include "longintrepr.h" /* We define bool_repr to return "False" or "True" */ diff --git a/Objects/longobject.c b/Objects/longobject.c index 66e164974a9..5325d1852bc 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -8,7 +8,6 @@ #include "pycore_long.h" // __PyLong_GetSmallInt_internal() #include "pycore_object.h" // _PyObject_InitVar() #include "pycore_pystate.h" // _Py_IsMainInterpreter() -#include "longintrepr.h" #include #include diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 877064e877d..0b0ff45621d 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -116,29 +116,31 @@ - - + + + + @@ -170,7 +172,6 @@ - @@ -224,7 +225,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index b8841c90cc1..17794fce88b 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -54,9 +54,6 @@ Include - - Include - Include @@ -69,9 +66,6 @@ Include - - Include - Include @@ -105,9 +99,6 @@ Include - - Include - Include @@ -120,9 +111,6 @@ Include - - Include - Include @@ -375,12 +363,18 @@ Include\cpython + + Include\cpython + Include\cpython Include + + Include\cpython + Include\cpython @@ -399,6 +393,9 @@ Include\cpython + + Include + Include @@ -456,6 +453,9 @@ Include\cpython + + Include + Include\cpython diff --git a/Python/marshal.c b/Python/marshal.c index e9ad566b71b..51c77555d9e 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -13,7 +13,6 @@ #include "pycore_code.h" // _PyCode_New() #include "pycore_floatobject.h" // _PyFloat_Pack8() #include "pycore_hashtable.h" // _Py_hashtable_t -#include "longintrepr.h" #include "code.h" #include "marshal.h" // Py_MARSHAL_VERSION