Skip to content

Commit 8e5de40

Browse files
authored
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.
1 parent 9ce9cfe commit 8e5de40

File tree

15 files changed

+39
-45
lines changed

15 files changed

+39
-45
lines changed

Doc/whatsnew/3.11.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ Porting to Python 3.11
572572
header provides functions like ``printf()`` and ``fopen()``.
573573
(Contributed by Victor Stinner in :issue:`45434`.)
574574

575-
* The non-limited API files ``cellobject.h`` and ``funcobject.h`` have been
575+
* The non-limited API files ``cellobject.h``, ``classobject.h``, ``context.h``,
576+
``funcobject.h``, ``genobject.h`` and ``longintrepr.h`` have been
576577
moved to the ``Include/cpython`` directory. These files must not be included
577578
directly, as they are already included in ``Python.h``: :ref:`Include Files
578579
<api-includes>`. If they have been included directly, consider including

Include/Python.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "bytesobject.h"
4747
#include "unicodeobject.h"
4848
#include "longobject.h"
49-
#include "longintrepr.h"
49+
#include "cpython/longintrepr.h"
5050
#include "boolobject.h"
5151
#include "floatobject.h"
5252
#include "complexobject.h"
@@ -61,7 +61,7 @@
6161
#include "methodobject.h"
6262
#include "moduleobject.h"
6363
#include "cpython/funcobject.h"
64-
#include "classobject.h"
64+
#include "cpython/classobject.h"
6565
#include "fileobject.h"
6666
#include "pycapsule.h"
6767
#include "code.h"
@@ -70,7 +70,8 @@
7070
#include "sliceobject.h"
7171
#include "cpython/cellobject.h"
7272
#include "iterobject.h"
73-
#include "genobject.h"
73+
#include "pystate.h"
74+
#include "cpython/genobject.h"
7475
#include "descrobject.h"
7576
#include "genericaliasobject.h"
7677
#include "warnings.h"
@@ -83,8 +84,7 @@
8384
#include "pyerrors.h"
8485
#include "cpython/initconfig.h"
8586
#include "pythread.h"
86-
#include "pystate.h"
87-
#include "context.h"
87+
#include "cpython/context.h"
8888
#include "modsupport.h"
8989
#include "compile.h"
9090
#include "pythonrun.h"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
5353
#ifdef __cplusplus
5454
}
5555
#endif
56-
#endif /* !Py_CLASSOBJECT_H */
57-
#endif /* Py_LIMITED_API */
56+
#endif // !Py_CLASSOBJECT_H
57+
#endif // !Py_LIMITED_API
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
#ifndef Py_LIMITED_API
12
#ifndef Py_CONTEXT_H
23
#define Py_CONTEXT_H
34
#ifdef __cplusplus
45
extern "C" {
56
#endif
67

7-
#ifndef Py_LIMITED_API
8-
9-
108
PyAPI_DATA(PyTypeObject) PyContext_Type;
119
typedef struct _pycontextobject PyContext;
1210

@@ -73,9 +71,8 @@ PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
7371
PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
7472

7573

76-
#endif /* !Py_LIMITED_API */
77-
7874
#ifdef __cplusplus
7975
}
8076
#endif
8177
#endif /* !Py_CONTEXT_H */
78+
#endif /* !Py_LIMITED_API */
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/* Generator object interface */
32

43
#ifndef Py_LIMITED_API
@@ -8,8 +7,7 @@
87
extern "C" {
98
#endif
109

11-
#include "pystate.h" /* _PyErr_StackItem */
12-
#include "abstract.h" /* PySendResult */
10+
/* --- Generators --------------------------------------------------------- */
1311

1412
/* _PyGenObject_HEAD defines the initial segment of generator
1513
and coroutine objects. */
@@ -45,7 +43,9 @@ PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
4543
PyObject *_PyGen_yf(PyGenObject *);
4644
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
4745

48-
#ifndef Py_LIMITED_API
46+
47+
/* --- PyCoroObject ------------------------------------------------------- */
48+
4949
typedef struct {
5050
_PyGenObject_HEAD(cr)
5151
PyObject *cr_origin;
@@ -59,7 +59,8 @@ PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
5959
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
6060
PyObject *name, PyObject *qualname);
6161

62-
/* Asynchronous Generators */
62+
63+
/* --- Asynchronous Generators -------------------------------------------- */
6364

6465
typedef struct {
6566
_PyGenObject_HEAD(ag)
@@ -89,7 +90,6 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
8990

9091
PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
9192

92-
#endif
9393

9494
#undef _PyGenObject_HEAD
9595

Makefile.pre.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,12 +1128,10 @@ PYTHON_HEADERS= \
11281128
$(srcdir)/Include/bytearrayobject.h \
11291129
$(srcdir)/Include/bytesobject.h \
11301130
$(srcdir)/Include/ceval.h \
1131-
$(srcdir)/Include/classobject.h \
11321131
$(srcdir)/Include/code.h \
11331132
$(srcdir)/Include/codecs.h \
11341133
$(srcdir)/Include/compile.h \
11351134
$(srcdir)/Include/complexobject.h \
1136-
$(srcdir)/Include/context.h \
11371135
$(srcdir)/Include/descrobject.h \
11381136
$(srcdir)/Include/dictobject.h \
11391137
$(srcdir)/Include/dynamic_annotations.h \
@@ -1144,13 +1142,11 @@ PYTHON_HEADERS= \
11441142
$(srcdir)/Include/fileutils.h \
11451143
$(srcdir)/Include/floatobject.h \
11461144
$(srcdir)/Include/frameobject.h \
1147-
$(srcdir)/Include/genobject.h \
11481145
$(srcdir)/Include/import.h \
11491146
$(srcdir)/Include/interpreteridobject.h \
11501147
$(srcdir)/Include/intrcheck.h \
11511148
$(srcdir)/Include/iterobject.h \
11521149
$(srcdir)/Include/listobject.h \
1153-
$(srcdir)/Include/longintrepr.h \
11541150
$(srcdir)/Include/longobject.h \
11551151
$(srcdir)/Include/marshal.h \
11561152
$(srcdir)/Include/memoryobject.h \
@@ -1202,18 +1198,22 @@ PYTHON_HEADERS= \
12021198
$(srcdir)/Include/cpython/bytesobject.h \
12031199
$(srcdir)/Include/cpython/cellobject.h \
12041200
$(srcdir)/Include/cpython/ceval.h \
1201+
$(srcdir)/Include/cpython/classobject.h \
12051202
$(srcdir)/Include/cpython/code.h \
12061203
$(srcdir)/Include/cpython/compile.h \
1204+
$(srcdir)/Include/cpython/context.h \
12071205
$(srcdir)/Include/cpython/dictobject.h \
12081206
$(srcdir)/Include/cpython/fileobject.h \
12091207
$(srcdir)/Include/cpython/fileutils.h \
12101208
$(srcdir)/Include/cpython/floatobject.h \
12111209
$(srcdir)/Include/cpython/frameobject.h \
12121210
$(srcdir)/Include/cpython/funcobject.h \
1211+
$(srcdir)/Include/cpython/genobject.h \
12131212
$(srcdir)/Include/cpython/import.h \
12141213
$(srcdir)/Include/cpython/initconfig.h \
12151214
$(srcdir)/Include/cpython/interpreteridobject.h \
12161215
$(srcdir)/Include/cpython/listobject.h \
1216+
$(srcdir)/Include/cpython/longintrepr.h \
12171217
$(srcdir)/Include/cpython/methodobject.h \
12181218
$(srcdir)/Include/cpython/object.h \
12191219
$(srcdir)/Include/cpython/objimpl.h \
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Move ``cellobject.h`` and ``funcobject.h`` header files from ``Include/`` to
1+
Move ``cellobject.h``, ``classobject.h``, ``context.h``, ``funcobject.h``,
2+
``genobject.h`` and ``longintrepr.h`` header files from ``Include/`` to
23
``Include/cpython/``. C extensions should only include the main ``<Python.h>``
34
header. Patch by Victor Stinner.

Modules/_decimal/_decimal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include <Python.h>
3030
#include "pycore_pystate.h" // _PyThreadState_GET()
31-
#include "longintrepr.h"
3231
#include "complexobject.h"
3332
#include "mpdecimal.h"
3433

Objects/abstract.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "pycore_unionobject.h" // _PyUnion_Check()
1111
#include <ctype.h>
1212
#include <stddef.h> // offsetof()
13-
#include "longintrepr.h"
1413

1514

1615

0 commit comments

Comments
 (0)