diff --git a/Include/Python.h b/Include/Python.h index d6e5b139ac6796..d446dec1e12de3 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -82,7 +82,6 @@ #error "PYMALLOC_DEBUG requires WITH_PYMALLOC" #endif #include "pymath.h" -#include "pytime.h" #include "pymem.h" #include "object.h" @@ -90,7 +89,10 @@ #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" @@ -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" @@ -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" @@ -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 */ diff --git a/Include/cellobject.h b/Include/cpython/cellobject.h similarity index 95% rename from Include/cellobject.h rename to Include/cpython/cellobject.h index 2f9b5b75d998ae..578294f64c9f58 100644 --- a/Include/cellobject.h +++ b/Include/cpython/cellobject.h @@ -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 @@ -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 */ diff --git a/Include/classobject.h b/Include/cpython/classobject.h similarity index 98% rename from Include/classobject.h rename to Include/cpython/classobject.h index 8742720720550c..0d9e6e6371389c 100644 --- a/Include/classobject.h +++ b/Include/cpython/classobject.h @@ -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 @@ -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 */ diff --git a/Include/genobject.h b/Include/cpython/genobject.h similarity index 97% rename from Include/genobject.h rename to Include/cpython/genobject.h index 5ee9a2831d12bf..c93f606148bcfa 100644 --- a/Include/genobject.h +++ b/Include/cpython/genobject.h @@ -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 @@ -102,5 +100,5 @@ int PyAsyncGen_ClearFreeLists(void); #ifdef __cplusplus } #endif +#endif /* !Py_LIMITED_API */ #endif /* !Py_GENOBJECT_H */ -#endif /* Py_LIMITED_API */ diff --git a/Include/pyarena.h b/Include/cpython/pyarena.h similarity index 98% rename from Include/pyarena.h rename to Include/cpython/pyarena.h index db3ad0188fe1cd..706c9506dc8cd2 100644 --- a/Include/pyarena.h +++ b/Include/cpython/pyarena.h @@ -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" { @@ -60,5 +60,5 @@ extern "C" { } #endif +#endif /* !Py_LIMITED_API */ #endif /* !Py_PYARENA_H */ -#endif /* Py_LIMITED_API */ diff --git a/Include/pyctype.h b/Include/cpython/pyctype.h similarity index 100% rename from Include/pyctype.h rename to Include/cpython/pyctype.h index 6bce63eeb63b82..477a446f2d58e8 100644 --- a/Include/pyctype.h +++ b/Include/cpython/pyctype.h @@ -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 @@ -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 */ diff --git a/Include/pydebug.h b/Include/cpython/pydebug.h similarity index 97% rename from Include/pydebug.h rename to Include/cpython/pydebug.h index bd4aafe3b49f83..46846b28258717 100644 --- a/Include/pydebug.h +++ b/Include/cpython/pydebug.h @@ -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 @@ -36,5 +36,5 @@ PyAPI_DATA(int) Py_LegacyWindowsStdioFlag; #ifdef __cplusplus } #endif +#endif /* !Py_LIMITED_API */ #endif /* !Py_PYDEBUG_H */ -#endif /* Py_LIMITED_API */ diff --git a/Include/pyfpe.h b/Include/cpython/pyfpe.h similarity index 91% rename from Include/pyfpe.h rename to Include/cpython/pyfpe.h index cc2def63aa5527..3d1a81bdaad924 100644 --- a/Include/pyfpe.h +++ b/Include/cpython/pyfpe.h @@ -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 */ diff --git a/Include/pytime.h b/Include/cpython/pytime.h similarity index 99% rename from Include/pytime.h rename to Include/cpython/pytime.h index bdda1da2e6b8f2..c8e3263b9e953b 100644 --- a/Include/pytime.h +++ b/Include/cpython/pytime.h @@ -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 @@ -242,5 +239,5 @@ PyAPI_FUNC(int) _PyTime_GetPerfCounterWithInfo( } #endif -#endif /* Py_PYTIME_H */ #endif /* Py_LIMITED_API */ +#endif /* Py_PYTIME_H */ diff --git a/Makefile.pre.in b/Makefile.pre.in index 3da104bac87d05..d27fe708f507b6 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -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 \ @@ -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 \ @@ -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 \ @@ -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 \ @@ -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 \ diff --git a/Misc/NEWS.d/next/C API/2020-02-12-21-32-39.bpo-35134.fw3-AJ.rst b/Misc/NEWS.d/next/C API/2020-02-12-21-32-39.bpo-35134.fw3-AJ.rst new file mode 100644 index 00000000000000..75c946def33a19 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2020-02-12-21-32-39.bpo-35134.fw3-AJ.rst @@ -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. diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index cf164c17d7bf17..82a5415f1f62e4 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -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; diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 36a27f467405d5..f086b9d659fe11 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -118,27 +118,33 @@ - - + + + + + + + + @@ -155,7 +161,6 @@ - @@ -206,16 +211,11 @@ - - - - - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 0301557b3e50d9..b61af2a81189fc 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -57,15 +57,9 @@ Include - - Include - Include - - Include - Include @@ -84,15 +78,24 @@ Include + + Include + Include + + Include + Include Include + + Include + Include @@ -108,9 +111,21 @@ Include + + Include + + + Include + + + Include + Include + + Include + Include @@ -120,6 +135,9 @@ Include + + Include + Include @@ -168,9 +186,6 @@ Include - - Include - Include @@ -309,36 +324,21 @@ Include - - Include - Include - - Include - - - Include - Include Include - - Include - Include Include - - Include - Include