bpo-35134: Move classobject.h to Include/cpython/ (GH-28968)

Move classobject.h, context.h, genobject.h and longintrepr.h header
files from Include/ to Include/cpython/.

Remove redundant "#ifndef Py_LIMITED_API" in context.h.

Remove explicit #include "longintrepr.h" in C files. It's not needed,
Python.h already includes it.
This commit is contained in:
Victor Stinner 2021-10-15 09:46:29 +02:00 committed by GitHub
parent 9ce9cfe595
commit 8e5de40f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 39 additions and 45 deletions

View File

@ -572,7 +572,8 @@ Porting to Python 3.11
header provides functions like ``printf()`` and ``fopen()``. header provides functions like ``printf()`` and ``fopen()``.
(Contributed by Victor Stinner in :issue:`45434`.) (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 moved to the ``Include/cpython`` directory. These files must not be included
directly, as they are already included in ``Python.h``: :ref:`Include Files directly, as they are already included in ``Python.h``: :ref:`Include Files
<api-includes>`. If they have been included directly, consider including <api-includes>`. If they have been included directly, consider including

View File

@ -46,7 +46,7 @@
#include "bytesobject.h" #include "bytesobject.h"
#include "unicodeobject.h" #include "unicodeobject.h"
#include "longobject.h" #include "longobject.h"
#include "longintrepr.h" #include "cpython/longintrepr.h"
#include "boolobject.h" #include "boolobject.h"
#include "floatobject.h" #include "floatobject.h"
#include "complexobject.h" #include "complexobject.h"
@ -61,7 +61,7 @@
#include "methodobject.h" #include "methodobject.h"
#include "moduleobject.h" #include "moduleobject.h"
#include "cpython/funcobject.h" #include "cpython/funcobject.h"
#include "classobject.h" #include "cpython/classobject.h"
#include "fileobject.h" #include "fileobject.h"
#include "pycapsule.h" #include "pycapsule.h"
#include "code.h" #include "code.h"
@ -70,7 +70,8 @@
#include "sliceobject.h" #include "sliceobject.h"
#include "cpython/cellobject.h" #include "cpython/cellobject.h"
#include "iterobject.h" #include "iterobject.h"
#include "genobject.h" #include "pystate.h"
#include "cpython/genobject.h"
#include "descrobject.h" #include "descrobject.h"
#include "genericaliasobject.h" #include "genericaliasobject.h"
#include "warnings.h" #include "warnings.h"
@ -83,8 +84,7 @@
#include "pyerrors.h" #include "pyerrors.h"
#include "cpython/initconfig.h" #include "cpython/initconfig.h"
#include "pythread.h" #include "pythread.h"
#include "pystate.h" #include "cpython/context.h"
#include "context.h"
#include "modsupport.h" #include "modsupport.h"
#include "compile.h" #include "compile.h"
#include "pythonrun.h" #include "pythonrun.h"

View File

@ -53,5 +53,5 @@ PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* !Py_CLASSOBJECT_H */ #endif // !Py_CLASSOBJECT_H
#endif /* Py_LIMITED_API */ #endif // !Py_LIMITED_API

View File

@ -1,12 +1,10 @@
#ifndef Py_LIMITED_API
#ifndef Py_CONTEXT_H #ifndef Py_CONTEXT_H
#define Py_CONTEXT_H #define Py_CONTEXT_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef Py_LIMITED_API
PyAPI_DATA(PyTypeObject) PyContext_Type; PyAPI_DATA(PyTypeObject) PyContext_Type;
typedef struct _pycontextobject PyContext; typedef struct _pycontextobject PyContext;
@ -73,9 +71,8 @@ PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void); PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
#endif /* !Py_LIMITED_API */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* !Py_CONTEXT_H */ #endif /* !Py_CONTEXT_H */
#endif /* !Py_LIMITED_API */

View File

@ -1,4 +1,3 @@
/* Generator object interface */ /* Generator object interface */
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
@ -8,8 +7,7 @@
extern "C" { extern "C" {
#endif #endif
#include "pystate.h" /* _PyErr_StackItem */ /* --- Generators --------------------------------------------------------- */
#include "abstract.h" /* PySendResult */
/* _PyGenObject_HEAD defines the initial segment of generator /* _PyGenObject_HEAD defines the initial segment of generator
and coroutine objects. */ and coroutine objects. */
@ -45,7 +43,9 @@ PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
PyObject *_PyGen_yf(PyGenObject *); PyObject *_PyGen_yf(PyGenObject *);
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self); PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
#ifndef Py_LIMITED_API
/* --- PyCoroObject ------------------------------------------------------- */
typedef struct { typedef struct {
_PyGenObject_HEAD(cr) _PyGenObject_HEAD(cr)
PyObject *cr_origin; PyObject *cr_origin;
@ -59,7 +59,8 @@ PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *, PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
PyObject *name, PyObject *qualname); PyObject *name, PyObject *qualname);
/* Asynchronous Generators */
/* --- Asynchronous Generators -------------------------------------------- */
typedef struct { typedef struct {
_PyGenObject_HEAD(ag) _PyGenObject_HEAD(ag)
@ -89,7 +90,6 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
PyObject *_PyAsyncGenValueWrapperNew(PyObject *); PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
#endif
#undef _PyGenObject_HEAD #undef _PyGenObject_HEAD

View File

@ -1128,12 +1128,10 @@ PYTHON_HEADERS= \
$(srcdir)/Include/bytearrayobject.h \ $(srcdir)/Include/bytearrayobject.h \
$(srcdir)/Include/bytesobject.h \ $(srcdir)/Include/bytesobject.h \
$(srcdir)/Include/ceval.h \ $(srcdir)/Include/ceval.h \
$(srcdir)/Include/classobject.h \
$(srcdir)/Include/code.h \ $(srcdir)/Include/code.h \
$(srcdir)/Include/codecs.h \ $(srcdir)/Include/codecs.h \
$(srcdir)/Include/compile.h \ $(srcdir)/Include/compile.h \
$(srcdir)/Include/complexobject.h \ $(srcdir)/Include/complexobject.h \
$(srcdir)/Include/context.h \
$(srcdir)/Include/descrobject.h \ $(srcdir)/Include/descrobject.h \
$(srcdir)/Include/dictobject.h \ $(srcdir)/Include/dictobject.h \
$(srcdir)/Include/dynamic_annotations.h \ $(srcdir)/Include/dynamic_annotations.h \
@ -1144,13 +1142,11 @@ PYTHON_HEADERS= \
$(srcdir)/Include/fileutils.h \ $(srcdir)/Include/fileutils.h \
$(srcdir)/Include/floatobject.h \ $(srcdir)/Include/floatobject.h \
$(srcdir)/Include/frameobject.h \ $(srcdir)/Include/frameobject.h \
$(srcdir)/Include/genobject.h \
$(srcdir)/Include/import.h \ $(srcdir)/Include/import.h \
$(srcdir)/Include/interpreteridobject.h \ $(srcdir)/Include/interpreteridobject.h \
$(srcdir)/Include/intrcheck.h \ $(srcdir)/Include/intrcheck.h \
$(srcdir)/Include/iterobject.h \ $(srcdir)/Include/iterobject.h \
$(srcdir)/Include/listobject.h \ $(srcdir)/Include/listobject.h \
$(srcdir)/Include/longintrepr.h \
$(srcdir)/Include/longobject.h \ $(srcdir)/Include/longobject.h \
$(srcdir)/Include/marshal.h \ $(srcdir)/Include/marshal.h \
$(srcdir)/Include/memoryobject.h \ $(srcdir)/Include/memoryobject.h \
@ -1202,18 +1198,22 @@ PYTHON_HEADERS= \
$(srcdir)/Include/cpython/bytesobject.h \ $(srcdir)/Include/cpython/bytesobject.h \
$(srcdir)/Include/cpython/cellobject.h \ $(srcdir)/Include/cpython/cellobject.h \
$(srcdir)/Include/cpython/ceval.h \ $(srcdir)/Include/cpython/ceval.h \
$(srcdir)/Include/cpython/classobject.h \
$(srcdir)/Include/cpython/code.h \ $(srcdir)/Include/cpython/code.h \
$(srcdir)/Include/cpython/compile.h \ $(srcdir)/Include/cpython/compile.h \
$(srcdir)/Include/cpython/context.h \
$(srcdir)/Include/cpython/dictobject.h \ $(srcdir)/Include/cpython/dictobject.h \
$(srcdir)/Include/cpython/fileobject.h \ $(srcdir)/Include/cpython/fileobject.h \
$(srcdir)/Include/cpython/fileutils.h \ $(srcdir)/Include/cpython/fileutils.h \
$(srcdir)/Include/cpython/floatobject.h \ $(srcdir)/Include/cpython/floatobject.h \
$(srcdir)/Include/cpython/frameobject.h \ $(srcdir)/Include/cpython/frameobject.h \
$(srcdir)/Include/cpython/funcobject.h \ $(srcdir)/Include/cpython/funcobject.h \
$(srcdir)/Include/cpython/genobject.h \
$(srcdir)/Include/cpython/import.h \ $(srcdir)/Include/cpython/import.h \
$(srcdir)/Include/cpython/initconfig.h \ $(srcdir)/Include/cpython/initconfig.h \
$(srcdir)/Include/cpython/interpreteridobject.h \ $(srcdir)/Include/cpython/interpreteridobject.h \
$(srcdir)/Include/cpython/listobject.h \ $(srcdir)/Include/cpython/listobject.h \
$(srcdir)/Include/cpython/longintrepr.h \
$(srcdir)/Include/cpython/methodobject.h \ $(srcdir)/Include/cpython/methodobject.h \
$(srcdir)/Include/cpython/object.h \ $(srcdir)/Include/cpython/object.h \
$(srcdir)/Include/cpython/objimpl.h \ $(srcdir)/Include/cpython/objimpl.h \

View File

@ -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 ``<Python.h>`` ``Include/cpython/``. C extensions should only include the main ``<Python.h>``
header. Patch by Victor Stinner. header. Patch by Victor Stinner.

View File

@ -28,7 +28,6 @@
#include <Python.h> #include <Python.h>
#include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_pystate.h" // _PyThreadState_GET()
#include "longintrepr.h"
#include "complexobject.h" #include "complexobject.h"
#include "mpdecimal.h" #include "mpdecimal.h"

View File

@ -10,7 +10,6 @@
#include "pycore_unionobject.h" // _PyUnion_Check() #include "pycore_unionobject.h" // _PyUnion_Check()
#include <ctype.h> #include <ctype.h>
#include <stddef.h> // offsetof() #include <stddef.h> // offsetof()
#include "longintrepr.h"

View File

@ -2,7 +2,6 @@
#include "Python.h" #include "Python.h"
#include "pycore_pyerrors.h" // _Py_FatalRefcountError() #include "pycore_pyerrors.h" // _Py_FatalRefcountError()
#include "longintrepr.h"
/* We define bool_repr to return "False" or "True" */ /* We define bool_repr to return "False" or "True" */

View File

@ -8,7 +8,6 @@
#include "pycore_long.h" // __PyLong_GetSmallInt_internal() #include "pycore_long.h" // __PyLong_GetSmallInt_internal()
#include "pycore_object.h" // _PyObject_InitVar() #include "pycore_object.h" // _PyObject_InitVar()
#include "pycore_pystate.h" // _Py_IsMainInterpreter() #include "pycore_pystate.h" // _Py_IsMainInterpreter()
#include "longintrepr.h"
#include <ctype.h> #include <ctype.h>
#include <float.h> #include <float.h>

View File

@ -116,29 +116,31 @@
<ClInclude Include="..\Include\bytearrayobject.h" /> <ClInclude Include="..\Include\bytearrayobject.h" />
<ClInclude Include="..\Include\bytesobject.h" /> <ClInclude Include="..\Include\bytesobject.h" />
<ClInclude Include="..\Include\ceval.h" /> <ClInclude Include="..\Include\ceval.h" />
<ClInclude Include="..\Include\classobject.h" />
<ClInclude Include="..\Include\code.h" /> <ClInclude Include="..\Include\code.h" />
<ClInclude Include="..\Include\codecs.h" /> <ClInclude Include="..\Include\codecs.h" />
<ClInclude Include="..\Include\compile.h" /> <ClInclude Include="..\Include\compile.h" />
<ClInclude Include="..\Include\complexobject.h" /> <ClInclude Include="..\Include\complexobject.h" />
<ClInclude Include="..\Include\context.h" />
<ClInclude Include="..\Include\cpython\abstract.h" /> <ClInclude Include="..\Include\cpython\abstract.h" />
<ClInclude Include="..\Include\cpython\bytearrayobject.h" /> <ClInclude Include="..\Include\cpython\bytearrayobject.h" />
<ClInclude Include="..\Include\cpython\bytesobject.h" /> <ClInclude Include="..\Include\cpython\bytesobject.h" />
<ClInclude Include="..\Include\cpython\cellobject.h" /> <ClInclude Include="..\Include\cpython\cellobject.h" />
<ClInclude Include="..\Include\cpython\ceval.h" /> <ClInclude Include="..\Include\cpython\ceval.h" />
<ClInclude Include="..\Include\cpython\classobject.h" />
<ClInclude Include="..\Include\cpython\code.h" /> <ClInclude Include="..\Include\cpython\code.h" />
<ClInclude Include="..\Include\cpython\compile.h" /> <ClInclude Include="..\Include\cpython\compile.h" />
<ClInclude Include="..\Include\cpython\context.h" />
<ClInclude Include="..\Include\cpython\dictobject.h" /> <ClInclude Include="..\Include\cpython\dictobject.h" />
<ClInclude Include="..\Include\cpython\fileobject.h" /> <ClInclude Include="..\Include\cpython\fileobject.h" />
<ClInclude Include="..\Include\cpython\fileutils.h" /> <ClInclude Include="..\Include\cpython\fileutils.h" />
<ClInclude Include="..\Include\cpython\floatobject.h" /> <ClInclude Include="..\Include\cpython\floatobject.h" />
<ClInclude Include="..\Include\cpython\frameobject.h" /> <ClInclude Include="..\Include\cpython\frameobject.h" />
<ClInclude Include="..\Include\cpython\funcobject.h" /> <ClInclude Include="..\Include\cpython\funcobject.h" />
<ClInclude Include="..\Include\cpython\genobject.h" />
<ClInclude Include="..\Include\cpython\import.h" /> <ClInclude Include="..\Include\cpython\import.h" />
<ClInclude Include="..\Include\cpython\initconfig.h" /> <ClInclude Include="..\Include\cpython\initconfig.h" />
<ClInclude Include="..\Include\cpython\interpreteridobject.h" /> <ClInclude Include="..\Include\cpython\interpreteridobject.h" />
<ClInclude Include="..\Include\cpython\listobject.h" /> <ClInclude Include="..\Include\cpython\listobject.h" />
<ClInclude Include="..\Include\cpython\longintrepr.h" />
<ClInclude Include="..\Include\cpython\methodobject.h" /> <ClInclude Include="..\Include\cpython\methodobject.h" />
<ClInclude Include="..\Include\cpython\object.h" /> <ClInclude Include="..\Include\cpython\object.h" />
<ClInclude Include="..\Include\cpython\objimpl.h" /> <ClInclude Include="..\Include\cpython\objimpl.h" />
@ -170,7 +172,6 @@
<ClInclude Include="..\Include\fileutils.h" /> <ClInclude Include="..\Include\fileutils.h" />
<ClInclude Include="..\Include\floatobject.h" /> <ClInclude Include="..\Include\floatobject.h" />
<ClInclude Include="..\Include\frameobject.h" /> <ClInclude Include="..\Include\frameobject.h" />
<ClInclude Include="..\Include\genobject.h" />
<ClInclude Include="..\Include\import.h" /> <ClInclude Include="..\Include\import.h" />
<ClInclude Include="..\Include\internal\pycore_abstract.h" /> <ClInclude Include="..\Include\internal\pycore_abstract.h" />
<ClInclude Include="..\Include\internal\pycore_accu.h" /> <ClInclude Include="..\Include\internal\pycore_accu.h" />
@ -224,7 +225,6 @@
<ClInclude Include="..\Include\intrcheck.h" /> <ClInclude Include="..\Include\intrcheck.h" />
<ClInclude Include="..\Include\iterobject.h" /> <ClInclude Include="..\Include\iterobject.h" />
<ClInclude Include="..\Include\listobject.h" /> <ClInclude Include="..\Include\listobject.h" />
<ClInclude Include="..\Include\longintrepr.h" />
<ClInclude Include="..\Include\longobject.h" /> <ClInclude Include="..\Include\longobject.h" />
<ClInclude Include="..\Include\marshal.h" /> <ClInclude Include="..\Include\marshal.h" />
<ClInclude Include="..\Include\memoryobject.h" /> <ClInclude Include="..\Include\memoryobject.h" />

View File

@ -54,9 +54,6 @@
<ClInclude Include="..\Include\ceval.h"> <ClInclude Include="..\Include\ceval.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\classobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\code.h"> <ClInclude Include="..\Include\code.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
@ -69,9 +66,6 @@
<ClInclude Include="..\Include\complexobject.h"> <ClInclude Include="..\Include\complexobject.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\context.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\datetime.h"> <ClInclude Include="..\Include\datetime.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
@ -105,9 +99,6 @@
<ClInclude Include="..\Include\frameobject.h"> <ClInclude Include="..\Include\frameobject.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\genobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\import.h"> <ClInclude Include="..\Include\import.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
@ -120,9 +111,6 @@
<ClInclude Include="..\Include\listobject.h"> <ClInclude Include="..\Include\listobject.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\longintrepr.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\longobject.h"> <ClInclude Include="..\Include\longobject.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
@ -375,12 +363,18 @@
<ClInclude Include="..\Include\cpython\ceval.h"> <ClInclude Include="..\Include\cpython\ceval.h">
<Filter>Include\cpython</Filter> <Filter>Include\cpython</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\cpython\classobject.h">
<Filter>Include\cpython</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\code.h"> <ClInclude Include="..\Include\cpython\code.h">
<Filter>Include\cpython</Filter> <Filter>Include\cpython</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\cpython\compile.h"> <ClInclude Include="..\Include\cpython\compile.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\cpython\context.h">
<Filter>Include\cpython</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\dictobject.h"> <ClInclude Include="..\Include\cpython\dictobject.h">
<Filter>Include\cpython</Filter> <Filter>Include\cpython</Filter>
</ClInclude> </ClInclude>
@ -399,6 +393,9 @@
<ClInclude Include="..\Include\cpython\listobject.h"> <ClInclude Include="..\Include\cpython\listobject.h">
<Filter>Include\cpython</Filter> <Filter>Include\cpython</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\cpython\longintrepr.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\odictobject.h"> <ClInclude Include="..\Include\cpython\odictobject.h">
<Filter>Include</Filter> <Filter>Include</Filter>
</ClInclude> </ClInclude>
@ -456,6 +453,9 @@
<ClInclude Include="..\Include\cpython\funcobject.h"> <ClInclude Include="..\Include\cpython\funcobject.h">
<Filter>Include\cpython</Filter> <Filter>Include\cpython</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\Include\cpython\genobject.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="..\Include\cpython\interpreteridobject.h"> <ClInclude Include="..\Include\cpython\interpreteridobject.h">
<Filter>Include\cpython</Filter> <Filter>Include\cpython</Filter>
</ClInclude> </ClInclude>

View File

@ -13,7 +13,6 @@
#include "pycore_code.h" // _PyCode_New() #include "pycore_code.h" // _PyCode_New()
#include "pycore_floatobject.h" // _PyFloat_Pack8() #include "pycore_floatobject.h" // _PyFloat_Pack8()
#include "pycore_hashtable.h" // _Py_hashtable_t #include "pycore_hashtable.h" // _Py_hashtable_t
#include "longintrepr.h"
#include "code.h" #include "code.h"
#include "marshal.h" // Py_MARSHAL_VERSION #include "marshal.h" // Py_MARSHAL_VERSION