Skip to content

[WIP] bpo-35134: Move header files to Include/cpython/ #18490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
#endif
#include "pymath.h"
#include "pytime.h"
#include "pymem.h"

#include "object.h"
#include "objimpl.h"
#include "typeslots.h"
#include "pyhash.h"

#include "pydebug.h"
/* object.h must be included before pytime.h which uses PyObject type */
#include "cpython/pytime.h"

#include "cpython/pydebug.h"

#include "bytearrayobject.h"
#include "bytesobject.h"
Expand All @@ -111,14 +113,13 @@
#include "methodobject.h"
#include "moduleobject.h"
#include "funcobject.h"
#include "classobject.h"
#include "cpython/classobject.h"
#include "fileobject.h"
#include "pycapsule.h"
#include "traceback.h"
#include "sliceobject.h"
#include "cellobject.h"
#include "cpython/cellobject.h"
#include "iterobject.h"
#include "genobject.h"
#include "descrobject.h"
#include "warnings.h"
#include "weakrefobject.h"
Expand All @@ -127,13 +128,17 @@
#include "picklebufobject.h"

#include "codecs.h"
#include "pyerrors.h"

#include "cpython/initconfig.h"
#include "pystate.h"
#include "context.h"

#include "pyarena.h"
/* pystate.h must be included before pyerrors.h and genobject.h
which use _PyErr_StackItem */
#include "pyerrors.h"
#include "cpython/genobject.h"

#include "context.h"
#include "cpython/pyarena.h"
#include "modsupport.h"
#include "compile.h"
#include "pythonrun.h"
Expand All @@ -149,12 +154,12 @@

#include "eval.h"

#include "pyctype.h"
#include "cpython/pyctype.h"
#include "pystrtod.h"
#include "pystrcmp.h"
#include "dtoa.h"
#include "fileutils.h"
#include "pyfpe.h"
#include "cpython/pyfpe.h"
#include "tracemalloc.h"

#endif /* !Py_PYTHON_H */
4 changes: 2 additions & 2 deletions Include/cellobject.h → Include/cpython/cellobject.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Cell object interface */
#ifndef Py_LIMITED_API
#ifndef Py_CELLOBJECT_H
#define Py_CELLOBJECT_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -25,5 +25,5 @@ PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_LIMITED_API */
#endif /* !Py_TUPLEOBJECT_H */
#endif /* Py_LIMITED_API */
4 changes: 2 additions & 2 deletions Include/classobject.h → Include/cpython/classobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

/* Revealing some structures (not for general use) */

#ifndef Py_LIMITED_API
#ifndef Py_CLASSOBJECT_H
#define Py_CLASSOBJECT_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -53,5 +53,5 @@ PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_LIMITED_API */
#endif /* !Py_CLASSOBJECT_H */
#endif /* Py_LIMITED_API */
6 changes: 2 additions & 4 deletions Include/genobject.h → Include/cpython/genobject.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

/* Generator object interface */

#ifndef Py_LIMITED_API
#ifndef Py_GENOBJECT_H
#define Py_GENOBJECT_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif

#include "pystate.h" /* _PyErr_StackItem */

struct _frame; /* Avoid including frameobject.h */

/* _PyGenObject_HEAD defines the initial segment of generator
Expand Down Expand Up @@ -102,5 +100,5 @@ int PyAsyncGen_ClearFreeLists(void);
#ifdef __cplusplus
}
#endif
#endif /* !Py_LIMITED_API */
#endif /* !Py_GENOBJECT_H */
#endif /* Py_LIMITED_API */
4 changes: 2 additions & 2 deletions Include/pyarena.h → Include/cpython/pyarena.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* An arena-like memory interface for the compiler.
*/

#ifndef Py_LIMITED_API
#ifndef Py_PYARENA_H
#define Py_PYARENA_H
#ifndef Py_LIMITED_API

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -60,5 +60,5 @@ extern "C" {
}
#endif

#endif /* !Py_LIMITED_API */
#endif /* !Py_PYARENA_H */
#endif /* Py_LIMITED_API */
4 changes: 2 additions & 2 deletions Include/pyctype.h → Include/cpython/pyctype.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef Py_LIMITED_API
#ifndef PYCTYPE_H
#define PYCTYPE_H
#ifndef Py_LIMITED_API

#define PY_CTF_LOWER 0x01
#define PY_CTF_UPPER 0x02
Expand Down Expand Up @@ -29,5 +29,5 @@ PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])

#endif /* !PYCTYPE_H */
#endif /* !Py_LIMITED_API */
#endif /* !PYCTYPE_H */
4 changes: 2 additions & 2 deletions Include/pydebug.h → Include/cpython/pydebug.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef Py_LIMITED_API
#ifndef Py_PYDEBUG_H
#define Py_PYDEBUG_H
#ifndef Py_LIMITED_API
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -36,5 +36,5 @@ PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
#ifdef __cplusplus
}
#endif
#endif /* !Py_LIMITED_API */
#endif /* !Py_PYDEBUG_H */
#endif /* Py_LIMITED_API */
2 changes: 1 addition & 1 deletion Include/pyfpe.h → Include/cpython/pyfpe.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#define PyFPE_START_PROTECT(err_string, leave_stmt)
#define PyFPE_END_PROTECT(v)

#endif /* !defined(Py_LIMITED_API) */
#endif /* !Py_LIMITED_API */
#endif /* !Py_PYFPE_H */
7 changes: 2 additions & 5 deletions Include/pytime.h → Include/cpython/pytime.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef Py_LIMITED_API
#ifndef Py_PYTIME_H
#define Py_PYTIME_H

#include "pyconfig.h" /* include for defines */
#include "object.h"
#ifndef Py_LIMITED_API

/**************************************************************************
Symbols and macros to supply platform-independent interfaces to time related
Expand Down Expand Up @@ -242,5 +239,5 @@ PyAPI_FUNC(int) _PyTime_GetPerfCounterWithInfo(
}
#endif

#endif /* Py_PYTIME_H */
#endif /* Py_LIMITED_API */
#endif /* Py_PYTIME_H */
16 changes: 8 additions & 8 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/bytearrayobject.h \
$(srcdir)/Include/bytes_methods.h \
$(srcdir)/Include/bytesobject.h \
$(srcdir)/Include/cellobject.h \
$(srcdir)/Include/ceval.h \
$(srcdir)/Include/classobject.h \
$(srcdir)/Include/code.h \
$(srcdir)/Include/codecs.h \
$(srcdir)/Include/compile.h \
Expand All @@ -992,7 +990,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/floatobject.h \
$(srcdir)/Include/frameobject.h \
$(srcdir)/Include/funcobject.h \
$(srcdir)/Include/genobject.h \
$(srcdir)/Include/import.h \
$(srcdir)/Include/interpreteridobject.h \
$(srcdir)/Include/intrcheck.h \
Expand All @@ -1015,13 +1012,9 @@ PYTHON_HEADERS= \
$(srcdir)/Include/osmodule.h \
$(srcdir)/Include/patchlevel.h \
$(srcdir)/Include/picklebufobject.h \
$(srcdir)/Include/pyarena.h \
$(srcdir)/Include/pycapsule.h \
$(srcdir)/Include/pyctype.h \
$(srcdir)/Include/pydebug.h \
$(srcdir)/Include/pydtrace.h \
$(srcdir)/Include/pyerrors.h \
$(srcdir)/Include/pyfpe.h \
$(srcdir)/Include/pyhash.h \
$(srcdir)/Include/pylifecycle.h \
$(srcdir)/Include/pymacconfig.h \
Expand All @@ -1035,7 +1028,6 @@ PYTHON_HEADERS= \
$(srcdir)/Include/pystrtod.h \
$(srcdir)/Include/pythonrun.h \
$(srcdir)/Include/pythread.h \
$(srcdir)/Include/pytime.h \
$(srcdir)/Include/rangeobject.h \
$(srcdir)/Include/setobject.h \
$(srcdir)/Include/sliceobject.h \
Expand All @@ -1057,19 +1049,27 @@ PYTHON_HEADERS= \
$(srcdir)/Include/Python-ast.h \
\
$(srcdir)/Include/cpython/abstract.h \
$(srcdir)/Include/cpython/cellobject.h \
$(srcdir)/Include/cpython/ceval.h \
$(srcdir)/Include/cpython/classobject.h \
$(srcdir)/Include/cpython/dictobject.h \
$(srcdir)/Include/cpython/fileobject.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/object.h \
$(srcdir)/Include/cpython/objimpl.h \
$(srcdir)/Include/cpython/pyarena.h \
$(srcdir)/Include/cpython/pyctype.h \
$(srcdir)/Include/cpython/pydebug.h \
$(srcdir)/Include/cpython/pyerrors.h \
$(srcdir)/Include/cpython/pyfpe.h \
$(srcdir)/Include/cpython/pylifecycle.h \
$(srcdir)/Include/cpython/pymem.h \
$(srcdir)/Include/cpython/pystate.h \
$(srcdir)/Include/cpython/pytime.h \
$(srcdir)/Include/cpython/sysmodule.h \
$(srcdir)/Include/cpython/traceback.h \
$(srcdir)/Include/cpython/tupleobject.h \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The whole content of cellobject.h, classobject.h, genobject.h, pyarena.h,
pyctype.h, pydebug.h, pyfpe.h and pytime.h is excluded from the limited C API,
so move these header files to Include/cpython/ directory. Since they are
included by the main Python.h: users should not be affected by this change. If
one of these header file is included explicitly: only include Python.h instead.
1 change: 0 additions & 1 deletion Modules/gcmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "pycore_pystate.h"
#include "frameobject.h" /* for PyFrame_ClearFreeList */
#include "pydtrace.h"
#include "pytime.h" /* for _PyTime_GetMonotonicClock() */

typedef struct _gc_runtime_state GCState;

Expand Down
16 changes: 8 additions & 8 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,33 @@
<ClInclude Include="..\Include\bytes_methods.h" />
<ClInclude Include="..\Include\bytearrayobject.h" />
<ClInclude Include="..\Include\bytesobject.h" />
<ClInclude Include="..\Include\cellobject.h" />
<ClInclude Include="..\Include\ceval.h" />
<ClInclude Include="..\Include\classobject.h" />
<ClInclude Include="..\Include\code.h" />
<ClInclude Include="..\Include\codecs.h" />
<ClInclude Include="..\Include\compile.h" />
<ClInclude Include="..\Include\complexobject.h" />
<ClInclude Include="..\Include\context.h" />
<ClInclude Include="..\Include\cpython\abstract.h" />
<ClInclude Include="..\Include\cpython\cellobject.h" />
<ClInclude Include="..\Include\cpython\ceval.h" />
<ClInclude Include="..\Include\cpython\classobject.h" />
<ClInclude Include="..\Include\cpython\dictobject.h" />
<ClInclude Include="..\Include\cpython\fileobject.h" />
<ClInclude Include="..\Include\cpython\genobject.h" />
<ClInclude Include="..\Include\cpython\import.h" />
<ClInclude Include="..\Include\cpython\initconfig.h" />
<ClInclude Include="..\Include\cpython\listobject.h" />
<ClInclude Include="..\Include\cpython\object.h" />
<ClInclude Include="..\Include\cpython\objimpl.h" />
<ClInclude Include="..\Include\cpython\pyarena.h" />
<ClInclude Include="..\Include\cpython\pyctype.h" />
<ClInclude Include="..\Include\cpython\pydebug.h" />
<ClInclude Include="..\Include\cpython\pyerrors.h" />
<ClInclude Include="..\Include\cpython\pyfpe.h" />
<ClInclude Include="..\Include\cpython\pylifecycle.h" />
<ClInclude Include="..\Include\cpython\pymem.h" />
<ClInclude Include="..\Include\cpython\pystate.h" />
<ClInclude Include="..\Include\cpython\pytime.h" />
<ClInclude Include="..\Include\cpython\sysmodule.h" />
<ClInclude Include="..\Include\cpython\traceback.h" />
<ClInclude Include="..\Include\cpython\tupleobject.h" />
Expand All @@ -155,7 +161,6 @@
<ClInclude Include="..\Include\floatobject.h" />
<ClInclude Include="..\Include\frameobject.h" />
<ClInclude Include="..\Include\funcobject.h" />
<ClInclude Include="..\Include\genobject.h" />
<ClInclude Include="..\Include\graminit.h" />
<ClInclude Include="..\Include\grammar.h" />
<ClInclude Include="..\Include\import.h" />
Expand Down Expand Up @@ -206,16 +211,11 @@
<ClInclude Include="..\Include\picklebufobject.h" />
<ClInclude Include="..\Include\pyhash.h" />
<ClInclude Include="..\Include\py_curses.h" />
<ClInclude Include="..\Include\pyarena.h" />
<ClInclude Include="..\Include\pycapsule.h" />
<ClInclude Include="..\Include\pyctype.h" />
<ClInclude Include="..\Include\pydebug.h" />
<ClInclude Include="..\Include\pyerrors.h" />
<ClInclude Include="..\Include\pyexpat.h" />
<ClInclude Include="..\Include\pyfpe.h" />
<ClInclude Include="..\Include\pylifecycle.h" />
<ClInclude Include="..\Include\pymath.h" />
<ClInclude Include="..\Include\pytime.h" />
<ClInclude Include="..\Include\pymacro.h" />
<ClInclude Include="..\Include\pymem.h" />
<ClInclude Include="..\Include\pyport.h" />
Expand Down
Loading