From edace60c2d367ec3c10689da5c05f1d4b4dc4844 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 29 Sep 2021 11:15:00 +0200 Subject: [PATCH 1/2] bpo-39026: Rename Include/cpython/ header files Header files of the Include/cpython/ subdirectory now get a "cpython_" prefix in their filename to avoid confusion between Include/
.h and Include/cpython/ (previously both files had the same name), especially when a cpython header file includes another cpython header file. Headers of the Include/cpython/ subdirectory cannot be included directly, so this change has no impact on the C API. cpython_pystate.h now includes "cpython_initconfig.h" rather than "cpython/initconfig.h" to fix building Python on macOS Framework. --- Include/Python.h | 14 ++-- Include/abstract.h | 2 +- Include/bytearrayobject.h | 2 +- Include/bytesobject.h | 2 +- Include/ceval.h | 2 +- Include/code.h | 2 +- Include/compile.h | 2 +- .../{abstract.h => cpython_abstract.h} | 0 ...rrayobject.h => cpython_bytearrayobject.h} | 0 .../{bytesobject.h => cpython_bytesobject.h} | 0 Include/cpython/{ceval.h => cpython_ceval.h} | 0 Include/cpython/{code.h => cpython_code.h} | 0 .../cpython/{compile.h => cpython_compile.h} | 0 .../{dictobject.h => cpython_dictobject.h} | 0 .../{fileobject.h => cpython_fileobject.h} | 0 .../{fileutils.h => cpython_fileutils.h} | 0 .../{frameobject.h => cpython_frameobject.h} | 0 .../cpython/{import.h => cpython_import.h} | 0 .../{initconfig.h => cpython_initconfig.h} | 0 ...object.h => cpython_interpreteridobject.h} | 0 .../{listobject.h => cpython_listobject.h} | 0 ...{methodobject.h => cpython_methodobject.h} | 0 .../cpython/{object.h => cpython_object.h} | 0 .../cpython/{objimpl.h => cpython_objimpl.h} | 0 .../{odictobject.h => cpython_odictobject.h} | 0 ...ebufobject.h => cpython_picklebufobject.h} | 0 .../cpython/{pyctype.h => cpython_pyctype.h} | 0 .../cpython/{pydebug.h => cpython_pydebug.h} | 0 .../{pyerrors.h => cpython_pyerrors.h} | 0 Include/cpython/{pyfpe.h => cpython_pyfpe.h} | 0 .../{pylifecycle.h => cpython_pylifecycle.h} | 0 Include/cpython/{pymem.h => cpython_pymem.h} | 0 .../cpython/{pystate.h => cpython_pystate.h} | 2 +- .../{pythonrun.h => cpython_pythonrun.h} | 0 .../cpython/{pytime.h => cpython_pytime.h} | 0 .../{sysmodule.h => cpython_sysmodule.h} | 0 .../{traceback.h => cpython_traceback.h} | 0 .../{tupleobject.h => cpython_tupleobject.h} | 0 ...nicodeobject.h => cpython_unicodeobject.h} | 0 Include/dictobject.h | 2 +- Include/fileobject.h | 2 +- Include/fileutils.h | 2 +- Include/frameobject.h | 2 +- Include/import.h | 2 +- Include/interpreteridobject.h | 2 +- Include/listobject.h | 2 +- Include/methodobject.h | 2 +- Include/object.h | 2 +- Include/objimpl.h | 2 +- Include/pyerrors.h | 2 +- Include/pylifecycle.h | 2 +- Include/pymem.h | 2 +- Include/pystate.h | 2 +- Include/pythonrun.h | 2 +- Include/sysmodule.h | 2 +- Include/traceback.h | 2 +- Include/tupleobject.h | 2 +- Include/unicodeobject.h | 2 +- Lib/__future__.py | 2 +- Makefile.pre.in | 64 +++++++++---------- .../2021-09-29-11-26-18.bpo-39026.p01JoG.rst | 4 ++ .../2021-09-29-11-24-32.bpo-39026.ttj5A1.rst | 6 ++ Tools/c-analyzer/cpython/_parser.py | 46 ++++++------- 63 files changed, 99 insertions(+), 89 deletions(-) rename Include/cpython/{abstract.h => cpython_abstract.h} (100%) rename Include/cpython/{bytearrayobject.h => cpython_bytearrayobject.h} (100%) rename Include/cpython/{bytesobject.h => cpython_bytesobject.h} (100%) rename Include/cpython/{ceval.h => cpython_ceval.h} (100%) rename Include/cpython/{code.h => cpython_code.h} (100%) rename Include/cpython/{compile.h => cpython_compile.h} (100%) rename Include/cpython/{dictobject.h => cpython_dictobject.h} (100%) rename Include/cpython/{fileobject.h => cpython_fileobject.h} (100%) rename Include/cpython/{fileutils.h => cpython_fileutils.h} (100%) rename Include/cpython/{frameobject.h => cpython_frameobject.h} (100%) rename Include/cpython/{import.h => cpython_import.h} (100%) rename Include/cpython/{initconfig.h => cpython_initconfig.h} (100%) rename Include/cpython/{interpreteridobject.h => cpython_interpreteridobject.h} (100%) rename Include/cpython/{listobject.h => cpython_listobject.h} (100%) rename Include/cpython/{methodobject.h => cpython_methodobject.h} (100%) rename Include/cpython/{object.h => cpython_object.h} (100%) rename Include/cpython/{objimpl.h => cpython_objimpl.h} (100%) rename Include/cpython/{odictobject.h => cpython_odictobject.h} (100%) rename Include/cpython/{picklebufobject.h => cpython_picklebufobject.h} (100%) rename Include/cpython/{pyctype.h => cpython_pyctype.h} (100%) rename Include/cpython/{pydebug.h => cpython_pydebug.h} (100%) rename Include/cpython/{pyerrors.h => cpython_pyerrors.h} (100%) rename Include/cpython/{pyfpe.h => cpython_pyfpe.h} (100%) rename Include/cpython/{pylifecycle.h => cpython_pylifecycle.h} (100%) rename Include/cpython/{pymem.h => cpython_pymem.h} (100%) rename Include/cpython/{pystate.h => cpython_pystate.h} (99%) rename Include/cpython/{pythonrun.h => cpython_pythonrun.h} (100%) rename Include/cpython/{pytime.h => cpython_pytime.h} (100%) rename Include/cpython/{sysmodule.h => cpython_sysmodule.h} (100%) rename Include/cpython/{traceback.h => cpython_traceback.h} (100%) rename Include/cpython/{tupleobject.h => cpython_tupleobject.h} (100%) rename Include/cpython/{unicodeobject.h => cpython_unicodeobject.h} (100%) create mode 100644 Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst create mode 100644 Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst diff --git a/Include/Python.h b/Include/Python.h index a83befa3117361..b44fe30b462a3d 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -76,7 +76,7 @@ #include "typeslots.h" #include "pyhash.h" -#include "cpython/pydebug.h" +#include "cpython/cpython_pydebug.h" #include "bytearrayobject.h" #include "bytesobject.h" @@ -91,7 +91,7 @@ #include "tupleobject.h" #include "listobject.h" #include "dictobject.h" -#include "cpython/odictobject.h" +#include "cpython/cpython_odictobject.h" #include "enumobject.h" #include "setobject.h" #include "methodobject.h" @@ -113,13 +113,13 @@ #include "weakrefobject.h" #include "structseq.h" #include "namespaceobject.h" -#include "cpython/picklebufobject.h" -#include "cpython/pytime.h" +#include "cpython/cpython_picklebufobject.h" +#include "cpython/cpython_pytime.h" #include "codecs.h" #include "pyerrors.h" -#include "cpython/initconfig.h" +#include "cpython/cpython_initconfig.h" #include "pythread.h" #include "pystate.h" #include "context.h" @@ -139,11 +139,11 @@ #include "eval.h" -#include "cpython/pyctype.h" +#include "cpython/cpython_pyctype.h" #include "pystrtod.h" #include "pystrcmp.h" #include "fileutils.h" -#include "cpython/pyfpe.h" +#include "cpython/cpython_pyfpe.h" #include "tracemalloc.h" #endif /* !Py_PYTHON_H */ diff --git a/Include/abstract.h b/Include/abstract.h index e8d3f9293b98d3..936b9c4aa306b1 100644 --- a/Include/abstract.h +++ b/Include/abstract.h @@ -863,7 +863,7 @@ PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); #ifndef Py_LIMITED_API # define Py_CPYTHON_ABSTRACTOBJECT_H -# include "cpython/abstract.h" +# include "cpython/cpython_abstract.h" # undef Py_CPYTHON_ABSTRACTOBJECT_H #endif diff --git a/Include/bytearrayobject.h b/Include/bytearrayobject.h index 9e95433f0f26f0..eb01623f290089 100644 --- a/Include/bytearrayobject.h +++ b/Include/bytearrayobject.h @@ -36,7 +36,7 @@ PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); #ifndef Py_LIMITED_API # define Py_CPYTHON_BYTEARRAYOBJECT_H -# include "cpython/bytearrayobject.h" +# include "cpython/cpython_bytearrayobject.h" # undef Py_CPYTHON_BYTEARRAYOBJECT_H #endif diff --git a/Include/bytesobject.h b/Include/bytesobject.h index 39c241a2dcf5f7..b4286e9c0d760a 100644 --- a/Include/bytesobject.h +++ b/Include/bytesobject.h @@ -59,7 +59,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize( #ifndef Py_LIMITED_API # define Py_CPYTHON_BYTESOBJECT_H -# include "cpython/bytesobject.h" +# include "cpython/cpython_bytesobject.h" # undef Py_CPYTHON_BYTESOBJECT_H #endif diff --git a/Include/ceval.h b/Include/ceval.h index 0f687666e2bccf..b87ad565dedbfa 100644 --- a/Include/ceval.h +++ b/Include/ceval.h @@ -148,7 +148,7 @@ PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); #ifndef Py_LIMITED_API # define Py_CPYTHON_CEVAL_H -# include "cpython/ceval.h" +# include "cpython/cpython_ceval.h" # undef Py_CPYTHON_CEVAL_H #endif diff --git a/Include/code.h b/Include/code.h index b9e23eb816529b..68558630a8e472 100644 --- a/Include/code.h +++ b/Include/code.h @@ -10,7 +10,7 @@ typedef struct PyCodeObject PyCodeObject; #ifndef Py_LIMITED_API # define Py_CPYTHON_CODE_H -# include "cpython/code.h" +# include "cpython/cpython_code.h" # undef Py_CPYTHON_CODE_H #endif diff --git a/Include/compile.h b/Include/compile.h index 3c5acd7209f763..9b6aae8609db58 100644 --- a/Include/compile.h +++ b/Include/compile.h @@ -15,7 +15,7 @@ extern "C" { #ifndef Py_LIMITED_API # define Py_CPYTHON_COMPILE_H -# include "cpython/compile.h" +# include "cpython/cpython_compile.h" # undef Py_CPYTHON_COMPILE_H #endif diff --git a/Include/cpython/abstract.h b/Include/cpython/cpython_abstract.h similarity index 100% rename from Include/cpython/abstract.h rename to Include/cpython/cpython_abstract.h diff --git a/Include/cpython/bytearrayobject.h b/Include/cpython/cpython_bytearrayobject.h similarity index 100% rename from Include/cpython/bytearrayobject.h rename to Include/cpython/cpython_bytearrayobject.h diff --git a/Include/cpython/bytesobject.h b/Include/cpython/cpython_bytesobject.h similarity index 100% rename from Include/cpython/bytesobject.h rename to Include/cpython/cpython_bytesobject.h diff --git a/Include/cpython/ceval.h b/Include/cpython/cpython_ceval.h similarity index 100% rename from Include/cpython/ceval.h rename to Include/cpython/cpython_ceval.h diff --git a/Include/cpython/code.h b/Include/cpython/cpython_code.h similarity index 100% rename from Include/cpython/code.h rename to Include/cpython/cpython_code.h diff --git a/Include/cpython/compile.h b/Include/cpython/cpython_compile.h similarity index 100% rename from Include/cpython/compile.h rename to Include/cpython/cpython_compile.h diff --git a/Include/cpython/dictobject.h b/Include/cpython/cpython_dictobject.h similarity index 100% rename from Include/cpython/dictobject.h rename to Include/cpython/cpython_dictobject.h diff --git a/Include/cpython/fileobject.h b/Include/cpython/cpython_fileobject.h similarity index 100% rename from Include/cpython/fileobject.h rename to Include/cpython/cpython_fileobject.h diff --git a/Include/cpython/fileutils.h b/Include/cpython/cpython_fileutils.h similarity index 100% rename from Include/cpython/fileutils.h rename to Include/cpython/cpython_fileutils.h diff --git a/Include/cpython/frameobject.h b/Include/cpython/cpython_frameobject.h similarity index 100% rename from Include/cpython/frameobject.h rename to Include/cpython/cpython_frameobject.h diff --git a/Include/cpython/import.h b/Include/cpython/cpython_import.h similarity index 100% rename from Include/cpython/import.h rename to Include/cpython/cpython_import.h diff --git a/Include/cpython/initconfig.h b/Include/cpython/cpython_initconfig.h similarity index 100% rename from Include/cpython/initconfig.h rename to Include/cpython/cpython_initconfig.h diff --git a/Include/cpython/interpreteridobject.h b/Include/cpython/cpython_interpreteridobject.h similarity index 100% rename from Include/cpython/interpreteridobject.h rename to Include/cpython/cpython_interpreteridobject.h diff --git a/Include/cpython/listobject.h b/Include/cpython/cpython_listobject.h similarity index 100% rename from Include/cpython/listobject.h rename to Include/cpython/cpython_listobject.h diff --git a/Include/cpython/methodobject.h b/Include/cpython/cpython_methodobject.h similarity index 100% rename from Include/cpython/methodobject.h rename to Include/cpython/cpython_methodobject.h diff --git a/Include/cpython/object.h b/Include/cpython/cpython_object.h similarity index 100% rename from Include/cpython/object.h rename to Include/cpython/cpython_object.h diff --git a/Include/cpython/objimpl.h b/Include/cpython/cpython_objimpl.h similarity index 100% rename from Include/cpython/objimpl.h rename to Include/cpython/cpython_objimpl.h diff --git a/Include/cpython/odictobject.h b/Include/cpython/cpython_odictobject.h similarity index 100% rename from Include/cpython/odictobject.h rename to Include/cpython/cpython_odictobject.h diff --git a/Include/cpython/picklebufobject.h b/Include/cpython/cpython_picklebufobject.h similarity index 100% rename from Include/cpython/picklebufobject.h rename to Include/cpython/cpython_picklebufobject.h diff --git a/Include/cpython/pyctype.h b/Include/cpython/cpython_pyctype.h similarity index 100% rename from Include/cpython/pyctype.h rename to Include/cpython/cpython_pyctype.h diff --git a/Include/cpython/pydebug.h b/Include/cpython/cpython_pydebug.h similarity index 100% rename from Include/cpython/pydebug.h rename to Include/cpython/cpython_pydebug.h diff --git a/Include/cpython/pyerrors.h b/Include/cpython/cpython_pyerrors.h similarity index 100% rename from Include/cpython/pyerrors.h rename to Include/cpython/cpython_pyerrors.h diff --git a/Include/cpython/pyfpe.h b/Include/cpython/cpython_pyfpe.h similarity index 100% rename from Include/cpython/pyfpe.h rename to Include/cpython/cpython_pyfpe.h diff --git a/Include/cpython/pylifecycle.h b/Include/cpython/cpython_pylifecycle.h similarity index 100% rename from Include/cpython/pylifecycle.h rename to Include/cpython/cpython_pylifecycle.h diff --git a/Include/cpython/pymem.h b/Include/cpython/cpython_pymem.h similarity index 100% rename from Include/cpython/pymem.h rename to Include/cpython/cpython_pymem.h diff --git a/Include/cpython/pystate.h b/Include/cpython/cpython_pystate.h similarity index 99% rename from Include/cpython/pystate.h rename to Include/cpython/cpython_pystate.h index ab4bf8bf8483c7..b1894cac59ad20 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/cpython_pystate.h @@ -2,7 +2,7 @@ # error "this header file must not be included directly" #endif -#include "cpython/initconfig.h" +#include "cpython_initconfig.h" PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *); PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int); diff --git a/Include/cpython/pythonrun.h b/Include/cpython/cpython_pythonrun.h similarity index 100% rename from Include/cpython/pythonrun.h rename to Include/cpython/cpython_pythonrun.h diff --git a/Include/cpython/pytime.h b/Include/cpython/cpython_pytime.h similarity index 100% rename from Include/cpython/pytime.h rename to Include/cpython/cpython_pytime.h diff --git a/Include/cpython/sysmodule.h b/Include/cpython/cpython_sysmodule.h similarity index 100% rename from Include/cpython/sysmodule.h rename to Include/cpython/cpython_sysmodule.h diff --git a/Include/cpython/traceback.h b/Include/cpython/cpython_traceback.h similarity index 100% rename from Include/cpython/traceback.h rename to Include/cpython/cpython_traceback.h diff --git a/Include/cpython/tupleobject.h b/Include/cpython/cpython_tupleobject.h similarity index 100% rename from Include/cpython/tupleobject.h rename to Include/cpython/cpython_tupleobject.h diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/cpython_unicodeobject.h similarity index 100% rename from Include/cpython/unicodeobject.h rename to Include/cpython/cpython_unicodeobject.h diff --git a/Include/dictobject.h b/Include/dictobject.h index da5a36ba07f32e..b521500f44b290 100644 --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -87,7 +87,7 @@ PyAPI_DATA(PyTypeObject) PyDictRevIterValue_Type; #ifndef Py_LIMITED_API # define Py_CPYTHON_DICTOBJECT_H -# include "cpython/dictobject.h" +# include "cpython/cpython_dictobject.h" # undef Py_CPYTHON_DICTOBJECT_H #endif diff --git a/Include/fileobject.h b/Include/fileobject.h index 6ec2994aa859b6..bbe9134c2ca61c 100644 --- a/Include/fileobject.h +++ b/Include/fileobject.h @@ -39,7 +39,7 @@ PyAPI_DATA(int) Py_UTF8Mode; #ifndef Py_LIMITED_API # define Py_CPYTHON_FILEOBJECT_H -# include "cpython/fileobject.h" +# include "cpython/cpython_fileobject.h" # undef Py_CPYTHON_FILEOBJECT_H #endif diff --git a/Include/fileutils.h b/Include/fileutils.h index 16f3b635deed89..bca2b09298e205 100644 --- a/Include/fileutils.h +++ b/Include/fileutils.h @@ -16,7 +16,7 @@ PyAPI_FUNC(char*) Py_EncodeLocale( #ifndef Py_LIMITED_API # define Py_CPYTHON_FILEUTILS_H -# include "cpython/fileutils.h" +# include "cpython/cpython_fileutils.h" # undef Py_CPYTHON_FILEUTILS_H #endif diff --git a/Include/frameobject.h b/Include/frameobject.h index c118af1201a4c8..53af18124b3948 100644 --- a/Include/frameobject.h +++ b/Include/frameobject.h @@ -10,7 +10,7 @@ extern "C" { #ifndef Py_LIMITED_API # define Py_CPYTHON_FRAMEOBJECT_H -# include "cpython/frameobject.h" +# include "cpython/cpython_frameobject.h" # undef Py_CPYTHON_FRAMEOBJECT_H #endif diff --git a/Include/import.h b/Include/import.h index aeef3efd0bcee8..d5e05ad613ffa5 100644 --- a/Include/import.h +++ b/Include/import.h @@ -88,7 +88,7 @@ PyAPI_FUNC(int) PyImport_AppendInittab( #ifndef Py_LIMITED_API # define Py_CPYTHON_IMPORT_H -# include "cpython/import.h" +# include "cpython/cpython_import.h" # undef Py_CPYTHON_IMPORT_H #endif diff --git a/Include/interpreteridobject.h b/Include/interpreteridobject.h index e744fcdc9ff189..fb6c98fc698817 100644 --- a/Include/interpreteridobject.h +++ b/Include/interpreteridobject.h @@ -7,7 +7,7 @@ extern "C" { #ifndef Py_LIMITED_API # define Py_CPYTHON_INTERPRETERIDOBJECT_H -# include "cpython/interpreteridobject.h" +# include "cpython/cpython_interpreteridobject.h" # undef Py_CPYTHON_INTERPRETERIDOBJECT_H #endif diff --git a/Include/listobject.h b/Include/listobject.h index 2a8a25525d1d7b..5062ff7520b999 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -42,7 +42,7 @@ PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); #ifndef Py_LIMITED_API # define Py_CPYTHON_LISTOBJECT_H -# include "cpython/listobject.h" +# include "cpython/cpython_listobject.h" # undef Py_CPYTHON_LISTOBJECT_H #endif diff --git a/Include/methodobject.h b/Include/methodobject.h index 9ffe8e1a3ddfcb..e79e2dbe479562 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -105,7 +105,7 @@ PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *, #ifndef Py_LIMITED_API #define Py_CPYTHON_METHODOBJECT_H -#include "cpython/methodobject.h" +#include "cpython/cpython_methodobject.h" #undef Py_CPYTHON_METHODOBJECT_H #endif diff --git a/Include/object.h b/Include/object.h index 490cbffd5f1074..152dcd1f13644f 100644 --- a/Include/object.h +++ b/Include/object.h @@ -723,7 +723,7 @@ times. #ifndef Py_LIMITED_API # define Py_CPYTHON_OBJECT_H -# include "cpython/object.h" +# include "cpython/cpython_object.h" # undef Py_CPYTHON_OBJECT_H #endif diff --git a/Include/objimpl.h b/Include/objimpl.h index 450befad679e70..4f06d3590183b8 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -205,7 +205,7 @@ PyAPI_FUNC(int) PyObject_GC_IsFinalized(PyObject *); #ifndef Py_LIMITED_API # define Py_CPYTHON_OBJIMPL_H -# include "cpython/objimpl.h" +# include "cpython/cpython_objimpl.h" # undef Py_CPYTHON_OBJIMPL_H #endif diff --git a/Include/pyerrors.h b/Include/pyerrors.h index f5d1c711577186..2d1a6c82528895 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -314,7 +314,7 @@ PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_l #ifndef Py_LIMITED_API # define Py_CPYTHON_ERRORS_H -# include "cpython/pyerrors.h" +# include "cpython/cpython_pyerrors.h" # undef Py_CPYTHON_ERRORS_H #endif diff --git a/Include/pylifecycle.h b/Include/pylifecycle.h index 9b2dd0868eb25b..e77faf61545982 100644 --- a/Include/pylifecycle.h +++ b/Include/pylifecycle.h @@ -64,7 +64,7 @@ PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); #ifndef Py_LIMITED_API # define Py_CPYTHON_PYLIFECYCLE_H -# include "cpython/pylifecycle.h" +# include "cpython/cpython_pylifecycle.h" # undef Py_CPYTHON_PYLIFECYCLE_H #endif diff --git a/Include/pymem.h b/Include/pymem.h index 66cdb0d2973cd0..564b46acc5e3a2 100644 --- a/Include/pymem.h +++ b/Include/pymem.h @@ -93,7 +93,7 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr); #ifndef Py_LIMITED_API # define Py_CPYTHON_PYMEM_H -# include "cpython/pymem.h" +# include "cpython/cpython_pymem.h" # undef Py_CPYTHON_PYMEM_H #endif diff --git a/Include/pystate.h b/Include/pystate.h index bae440778b261a..6b71d9b85e049f 100644 --- a/Include/pystate.h +++ b/Include/pystate.h @@ -140,7 +140,7 @@ PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); #ifndef Py_LIMITED_API # define Py_CPYTHON_PYSTATE_H -# include "cpython/pystate.h" +# include "cpython/cpython_pystate.h" # undef Py_CPYTHON_PYSTATE_H #endif diff --git a/Include/pythonrun.h b/Include/pythonrun.h index b0a2fc3002d37d..305df64c22c756 100644 --- a/Include/pythonrun.h +++ b/Include/pythonrun.h @@ -34,7 +34,7 @@ PyAPI_FUNC(int) PyOS_CheckStack(void); #ifndef Py_LIMITED_API # define Py_CPYTHON_PYTHONRUN_H -# include "cpython/pythonrun.h" +# include "cpython/cpython_pythonrun.h" # undef Py_CPYTHON_PYTHONRUN_H #endif diff --git a/Include/sysmodule.h b/Include/sysmodule.h index 8c8f7c425942a5..c6cd1a7b192176 100644 --- a/Include/sysmodule.h +++ b/Include/sysmodule.h @@ -31,7 +31,7 @@ PyAPI_FUNC(PyObject *) PySys_GetXOptions(void); #ifndef Py_LIMITED_API # define Py_CPYTHON_SYSMODULE_H -# include "cpython/sysmodule.h" +# include "cpython/cpython_sysmodule.h" # undef Py_CPYTHON_SYSMODULE_H #endif diff --git a/Include/traceback.h b/Include/traceback.h index 781e5a6eec4edd..ba19b58ebb2934 100644 --- a/Include/traceback.h +++ b/Include/traceback.h @@ -16,7 +16,7 @@ PyAPI_DATA(PyTypeObject) PyTraceBack_Type; #ifndef Py_LIMITED_API # define Py_CPYTHON_TRACEBACK_H -# include "cpython/traceback.h" +# include "cpython/cpython_traceback.h" # undef Py_CPYTHON_TRACEBACK_H #endif diff --git a/Include/tupleobject.h b/Include/tupleobject.h index e796a320192c20..06525f940ac5ae 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -36,7 +36,7 @@ PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); #ifndef Py_LIMITED_API # define Py_CPYTHON_TUPLEOBJECT_H -# include "cpython/tupleobject.h" +# include "cpython/cpython_tupleobject.h" # undef Py_CPYTHON_TUPLEOBJECT_H #endif diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index b0ac086a6be23d..d0e91f24c2b2ed 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -1043,7 +1043,7 @@ PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s); #ifndef Py_LIMITED_API # define Py_CPYTHON_UNICODEOBJECT_H -# include "cpython/unicodeobject.h" +# include "cpython/cpython_unicodeobject.h" # undef Py_CPYTHON_UNICODEOBJECT_H #endif diff --git a/Lib/__future__.py b/Lib/__future__.py index 97dc90c6e4644a..3abe6cd9498ae7 100644 --- a/Lib/__future__.py +++ b/Lib/__future__.py @@ -42,7 +42,7 @@ argument to the builtin function compile() to enable the feature in dynamically compiled code. This flag is stored in the .compiler_flag attribute on _Future instances. These values must match the appropriate -#defines of CO_xxx flags in Include/cpython/compile.h. +#defines of CO_xxx flags in Include/cpython/cpython_compile.h. No feature line is ever to be deleted from this file. """ diff --git a/Makefile.pre.in b/Makefile.pre.in index 5564c1bae1ce2a..278524bb336b23 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1175,38 +1175,38 @@ PYTHON_HEADERS= \ pyconfig.h \ $(PARSER_HEADERS) \ \ - $(srcdir)/Include/cpython/abstract.h \ - $(srcdir)/Include/cpython/bytearrayobject.h \ - $(srcdir)/Include/cpython/bytesobject.h \ - $(srcdir)/Include/cpython/ceval.h \ - $(srcdir)/Include/cpython/code.h \ - $(srcdir)/Include/cpython/compile.h \ - $(srcdir)/Include/cpython/dictobject.h \ - $(srcdir)/Include/cpython/fileobject.h \ - $(srcdir)/Include/cpython/fileutils.h \ - $(srcdir)/Include/cpython/frameobject.h \ - $(srcdir)/Include/cpython/import.h \ - $(srcdir)/Include/cpython/initconfig.h \ - $(srcdir)/Include/cpython/interpreteridobject.h \ - $(srcdir)/Include/cpython/listobject.h \ - $(srcdir)/Include/cpython/methodobject.h \ - $(srcdir)/Include/cpython/object.h \ - $(srcdir)/Include/cpython/objimpl.h \ - $(srcdir)/Include/cpython/odictobject.h \ - $(srcdir)/Include/cpython/picklebufobject.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/pythonrun.h \ - $(srcdir)/Include/cpython/pytime.h \ - $(srcdir)/Include/cpython/sysmodule.h \ - $(srcdir)/Include/cpython/traceback.h \ - $(srcdir)/Include/cpython/tupleobject.h \ - $(srcdir)/Include/cpython/unicodeobject.h \ + $(srcdir)/Include/cpython/cpython_abstract.h \ + $(srcdir)/Include/cpython/cpython_bytearrayobject.h \ + $(srcdir)/Include/cpython/cpython_bytesobject.h \ + $(srcdir)/Include/cpython/cpython_ceval.h \ + $(srcdir)/Include/cpython/cpython_code.h \ + $(srcdir)/Include/cpython/cpython_compile.h \ + $(srcdir)/Include/cpython/cpython_dictobject.h \ + $(srcdir)/Include/cpython/cpython_fileobject.h \ + $(srcdir)/Include/cpython/cpython_fileutils.h \ + $(srcdir)/Include/cpython/cpython_frameobject.h \ + $(srcdir)/Include/cpython/cpython_import.h \ + $(srcdir)/Include/cpython/cpython_initconfig.h \ + $(srcdir)/Include/cpython/cpython_interpreteridobject.h \ + $(srcdir)/Include/cpython/cpython_listobject.h \ + $(srcdir)/Include/cpython/cpython_methodobject.h \ + $(srcdir)/Include/cpython/cpython_object.h \ + $(srcdir)/Include/cpython/cpython_objimpl.h \ + $(srcdir)/Include/cpython/cpython_odictobject.h \ + $(srcdir)/Include/cpython/cpython_picklebufobject.h \ + $(srcdir)/Include/cpython/cpython_pyctype.h \ + $(srcdir)/Include/cpython/cpython_pydebug.h \ + $(srcdir)/Include/cpython/cpython_pyerrors.h \ + $(srcdir)/Include/cpython/cpython_pyfpe.h \ + $(srcdir)/Include/cpython/cpython_pylifecycle.h \ + $(srcdir)/Include/cpython/cpython_pymem.h \ + $(srcdir)/Include/cpython/cpython_pystate.h \ + $(srcdir)/Include/cpython/cpython_pythonrun.h \ + $(srcdir)/Include/cpython/cpython_pytime.h \ + $(srcdir)/Include/cpython/cpython_sysmodule.h \ + $(srcdir)/Include/cpython/cpython_traceback.h \ + $(srcdir)/Include/cpython/cpython_tupleobject.h \ + $(srcdir)/Include/cpython/cpython_unicodeobject.h \ \ $(srcdir)/Include/internal/pycore_abstract.h \ $(srcdir)/Include/internal/pycore_accu.h \ diff --git a/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst b/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst new file mode 100644 index 00000000000000..2502720cc563c6 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst @@ -0,0 +1,4 @@ +Fix building Python on macOS Framework: fix include from +Include/cpython/pystate.h to Include/cpython/initconfig.h. Header files of +the Include/cpython/ subdirectory now get a "cpython_" prefix in their +filename to avoid confusion. diff --git a/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst b/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst new file mode 100644 index 00000000000000..022225b69a743b --- /dev/null +++ b/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst @@ -0,0 +1,6 @@ +Header files of the ``Include/cpython/`` subdirectory now get a "cpython_" +prefix in their filename to avoid confusion between ``Include/
.h`` +and ``Include/cpython/`` (previously both files had the same +name), especially when a cpython header file includes another cpython header +file. Headers of the ``Include/cpython/`` subdirectory cannot be included +directly, so this change has no impact on the C API. diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index ef06a9fcb69033..a0072a8657f558 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -162,29 +162,29 @@ def clean_lines(text): Modules/_pickle.c Py_BUILD_CORE_BUILTIN 1 Modules/_testinternalcapi.c Py_BUILD_CORE_BUILTIN 1 -Include/cpython/abstract.h Py_CPYTHON_ABSTRACTOBJECT_H 1 -Include/cpython/bytearrayobject.h Py_CPYTHON_BYTEARRAYOBJECT_H 1 -Include/cpython/bytesobject.h Py_CPYTHON_BYTESOBJECT_H 1 -Include/cpython/ceval.h Py_CPYTHON_CEVAL_H 1 -Include/cpython/code.h Py_CPYTHON_CODE_H 1 -Include/cpython/dictobject.h Py_CPYTHON_DICTOBJECT_H 1 -Include/cpython/fileobject.h Py_CPYTHON_FILEOBJECT_H 1 -Include/cpython/fileutils.h Py_CPYTHON_FILEUTILS_H 1 -Include/cpython/frameobject.h Py_CPYTHON_FRAMEOBJECT_H 1 -Include/cpython/import.h Py_CPYTHON_IMPORT_H 1 -Include/cpython/interpreteridobject.h Py_CPYTHON_INTERPRETERIDOBJECT_H 1 -Include/cpython/listobject.h Py_CPYTHON_LISTOBJECT_H 1 -Include/cpython/methodobject.h Py_CPYTHON_METHODOBJECT_H 1 -Include/cpython/object.h Py_CPYTHON_OBJECT_H 1 -Include/cpython/objimpl.h Py_CPYTHON_OBJIMPL_H 1 -Include/cpython/pyerrors.h Py_CPYTHON_ERRORS_H 1 -Include/cpython/pylifecycle.h Py_CPYTHON_PYLIFECYCLE_H 1 -Include/cpython/pymem.h Py_CPYTHON_PYMEM_H 1 -Include/cpython/pystate.h Py_CPYTHON_PYSTATE_H 1 -Include/cpython/sysmodule.h Py_CPYTHON_SYSMODULE_H 1 -Include/cpython/traceback.h Py_CPYTHON_TRACEBACK_H 1 -Include/cpython/tupleobject.h Py_CPYTHON_TUPLEOBJECT_H 1 -Include/cpython/unicodeobject.h Py_CPYTHON_UNICODEOBJECT_H 1 +Include/cpython/cpython_abstract.h Py_CPYTHON_ABSTRACTOBJECT_H 1 +Include/cpython/cpython_bytearrayobject.h Py_CPYTHON_BYTEARRAYOBJECT_H 1 +Include/cpython/cpython_bytesobject.h Py_CPYTHON_BYTESOBJECT_H 1 +Include/cpython/cpython_ceval.h Py_CPYTHON_CEVAL_H 1 +Include/cpython/cpython_code.h Py_CPYTHON_CODE_H 1 +Include/cpython/cpython_dictobject.h Py_CPYTHON_DICTOBJECT_H 1 +Include/cpython/cpython_fileobject.h Py_CPYTHON_FILEOBJECT_H 1 +Include/cpython/cpython_fileutils.h Py_CPYTHON_FILEUTILS_H 1 +Include/cpython/cpython_frameobject.h Py_CPYTHON_FRAMEOBJECT_H 1 +Include/cpython/cpython_import.h Py_CPYTHON_IMPORT_H 1 +Include/cpython/cpython_interpreteridobject.h Py_CPYTHON_INTERPRETERIDOBJECT_H 1 +Include/cpython/cpython_listobject.h Py_CPYTHON_LISTOBJECT_H 1 +Include/cpython/cpython_methodobject.h Py_CPYTHON_METHODOBJECT_H 1 +Include/cpython/cpython_object.h Py_CPYTHON_OBJECT_H 1 +Include/cpython/cpython_objimpl.h Py_CPYTHON_OBJIMPL_H 1 +Include/cpython/cpython_pyerrors.h Py_CPYTHON_ERRORS_H 1 +Include/cpython/cpython_pylifecycle.h Py_CPYTHON_PYLIFECYCLE_H 1 +Include/cpython/cpython_pymem.h Py_CPYTHON_PYMEM_H 1 +Include/cpython/cpython_pystate.h Py_CPYTHON_PYSTATE_H 1 +Include/cpython/cpython_sysmodule.h Py_CPYTHON_SYSMODULE_H 1 +Include/cpython/cpython_traceback.h Py_CPYTHON_TRACEBACK_H 1 +Include/cpython/cpython_tupleobject.h Py_CPYTHON_TUPLEOBJECT_H 1 +Include/cpython/cpython_unicodeobject.h Py_CPYTHON_UNICODEOBJECT_H 1 # implied include of pyport.h Include/**/*.h PyAPI_DATA(RTYPE) extern RTYPE From 5e28f1e2834f223115958e0413f050074bd03246 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 29 Sep 2021 11:40:36 +0200 Subject: [PATCH 2/2] Fix documentation build --- Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst | 2 +- Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst b/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst index 2502720cc563c6..c8bf740dfa1d4f 100644 --- a/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst +++ b/Misc/NEWS.d/next/Build/2021-09-29-11-26-18.bpo-39026.p01JoG.rst @@ -1,4 +1,4 @@ Fix building Python on macOS Framework: fix include from Include/cpython/pystate.h to Include/cpython/initconfig.h. Header files of -the Include/cpython/ subdirectory now get a "cpython_" prefix in their +the Include/cpython/ subdirectory now get a ``cpython_`` prefix in their filename to avoid confusion. diff --git a/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst b/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst index 022225b69a743b..69cf26bfee23a8 100644 --- a/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst +++ b/Misc/NEWS.d/next/C API/2021-09-29-11-24-32.bpo-39026.ttj5A1.rst @@ -1,4 +1,4 @@ -Header files of the ``Include/cpython/`` subdirectory now get a "cpython_" +Header files of the ``Include/cpython/`` subdirectory now get a ``cpython_`` prefix in their filename to avoid confusion between ``Include/
.h`` and ``Include/cpython/`` (previously both files had the same name), especially when a cpython header file includes another cpython header