From bf5a48c5f16f5881834bd55f317f2525b5022496 Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 13:12:36 +0800 Subject: [PATCH 1/8] Move Include/asdl.h to Include/cpython/asdl.h --- Include/Python-ast.h | 2 +- Include/Python.h | 1 + Include/{ => cpython}/asdl.h | 0 Makefile.pre.in | 2 +- PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 6 +++--- Parser/asdl_c.py | 2 +- Python/asdl.c | 1 - 8 files changed, 8 insertions(+), 8 deletions(-) rename Include/{ => cpython}/asdl.h (100%) diff --git a/Include/Python-ast.h b/Include/Python-ast.h index bd127ca2ab0cad..dcbd6b43ac51f8 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef Py_LIMITED_API -#include "asdl.h" +#include "Python.h" #undef Yield /* undefine macro conflicting with */ diff --git a/Include/Python.h b/Include/Python.h index 86dbbcf6bd85da..94db06b07b3b39 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -160,5 +160,6 @@ #include "fileutils.h" #include "cpython/pyfpe.h" #include "tracemalloc.h" +#include "cpython/asdl.h" #endif /* !Py_PYTHON_H */ diff --git a/Include/asdl.h b/Include/cpython/asdl.h similarity index 100% rename from Include/asdl.h rename to Include/cpython/asdl.h diff --git a/Makefile.pre.in b/Makefile.pre.in index 0f59700952989e..80bf7d41e192d7 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1015,7 +1015,6 @@ regen-typeslots: PYTHON_HEADERS= \ $(srcdir)/Include/Python.h \ $(srcdir)/Include/abstract.h \ - $(srcdir)/Include/asdl.h \ $(srcdir)/Include/ast.h \ $(srcdir)/Include/bltinmodule.h \ $(srcdir)/Include/boolobject.h \ @@ -1097,6 +1096,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/Python-ast.h \ \ $(srcdir)/Include/cpython/abstract.h \ + $(srcdir)/Include/cpython/asdl.h \ $(srcdir)/Include/cpython/bytearrayobject.h \ $(srcdir)/Include/cpython/bytesobject.h \ $(srcdir)/Include/cpython/ceval.h \ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 92355a886d91a7..536a8bf5267009 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -113,7 +113,6 @@ - @@ -127,6 +126,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index d0b69dbc5b64fd..23f4579a9cf615 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -42,9 +42,6 @@ Include - - Include - Include @@ -381,6 +378,9 @@ Include\cpython + + Include + Include\cpython diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 8c167bc79c779b..4b03fc7b221fa1 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1498,7 +1498,7 @@ def write_header(mod, f): f.write('#endif\n') f.write('\n') f.write('#ifndef Py_LIMITED_API\n') - f.write('#include "asdl.h"\n') + f.write('#include "Python.h"\n') f.write('\n') f.write('#undef Yield /* undefine macro conflicting with */\n') f.write('\n') diff --git a/Python/asdl.c b/Python/asdl.c index 4ff07e4377b18e..04564c8d71d910 100644 --- a/Python/asdl.c +++ b/Python/asdl.c @@ -1,5 +1,4 @@ #include "Python.h" -#include "asdl.h" GENERATE_ASDL_SEQ_CONSTRUCTOR(generic, void*); GENERATE_ASDL_SEQ_CONSTRUCTOR(identifier, PyObject*); From 58d1ad6976fb9f8943e1a1a7a4a9d3a43a0f0c6c Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 13:14:43 +0800 Subject: [PATCH 2/8] Move Include/pystrhex.h to Include/cpython/pystrhex.h --- Include/Python.h | 1 + Include/{ => cpython}/pystrhex.h | 0 Makefile.pre.in | 2 +- Modules/_blake2/blake2b_impl.c | 1 - Modules/_blake2/blake2s_impl.c | 1 - Modules/_hashopenssl.c | 1 - Modules/_sha3/sha3module.c | 1 - Modules/binascii.c | 1 - Modules/md5module.c | 1 - Modules/sha1module.c | 1 - Modules/sha256module.c | 1 - Modules/sha512module.c | 1 - Objects/bytearrayobject.c | 1 - Objects/bytesobject.c | 1 - Objects/memoryobject.c | 1 - PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 6 +++--- Python/pystrhex.c | 2 -- 18 files changed, 6 insertions(+), 19 deletions(-) rename Include/{ => cpython}/pystrhex.h (100%) diff --git a/Include/Python.h b/Include/Python.h index 94db06b07b3b39..ec996411c7c937 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -157,6 +157,7 @@ #include "cpython/pyctype.h" #include "pystrtod.h" #include "pystrcmp.h" +#include "cpython/pystrhex.h" #include "fileutils.h" #include "cpython/pyfpe.h" #include "tracemalloc.h" diff --git a/Include/pystrhex.h b/Include/cpython/pystrhex.h similarity index 100% rename from Include/pystrhex.h rename to Include/cpython/pystrhex.h diff --git a/Makefile.pre.in b/Makefile.pre.in index 80bf7d41e192d7..cc647bf5c21c46 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1072,7 +1072,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/pyport.h \ $(srcdir)/Include/pystate.h \ $(srcdir)/Include/pystrcmp.h \ - $(srcdir)/Include/pystrhex.h \ $(srcdir)/Include/pystrtod.h \ $(srcdir)/Include/pythonrun.h \ $(srcdir)/Include/pythread.h \ @@ -1122,6 +1121,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/pylifecycle.h \ $(srcdir)/Include/cpython/pymem.h \ $(srcdir)/Include/cpython/pystate.h \ + $(srcdir)/Include/cpython/pystrhex.h \ $(srcdir)/Include/cpython/pythonrun.h \ $(srcdir)/Include/cpython/pytime.h \ $(srcdir)/Include/cpython/sysmodule.h \ diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index 5d108ed008a8a1..3983aa03a171c4 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -14,7 +14,6 @@ */ #include "Python.h" -#include "pystrhex.h" #include "../hashlib.h" #include "blake2ns.h" diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index 85c2d4edad7eee..19799073002f2f 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -14,7 +14,6 @@ */ #include "Python.h" -#include "pystrhex.h" #include "../hashlib.h" #include "blake2ns.h" diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index d4295d7c3638d6..e2ef2565620c17 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -15,7 +15,6 @@ #include "Python.h" #include "hashlib.h" -#include "pystrhex.h" /* EVP is the preferred interface to hashing in OpenSSL */ diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index cae10f99d5b8df..438d4b49d0b963 100644 --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -16,7 +16,6 @@ */ #include "Python.h" -#include "pystrhex.h" #include "../hashlib.h" /* ************************************************************************** diff --git a/Modules/binascii.c b/Modules/binascii.c index 1f3248b6049b31..fc1ca55b873633 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -56,7 +56,6 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pystrhex.h" #ifdef USE_ZLIB_CRC32 #include "zlib.h" #endif diff --git a/Modules/md5module.c b/Modules/md5module.c index b2e65a0a5ffd22..bf43bc7847a1f5 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -18,7 +18,6 @@ #include "Python.h" #include "hashlib.h" -#include "pystrhex.h" /*[clinic input] module _md5 diff --git a/Modules/sha1module.c b/Modules/sha1module.c index 7126db93b1a3fc..cf6a59c67a3e68 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -18,7 +18,6 @@ #include "Python.h" #include "hashlib.h" -#include "pystrhex.h" /*[clinic input] module _sha1 diff --git a/Modules/sha256module.c b/Modules/sha256module.c index b90e5df7826740..aff8b1273c2a8b 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -20,7 +20,6 @@ #include "pycore_bitutils.h" // _Py_bswap32() #include "structmember.h" // PyMemberDef #include "hashlib.h" -#include "pystrhex.h" /*[clinic input] module _sha256 diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 0d8f51e5ae5e00..df13e1e6399958 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -20,7 +20,6 @@ #include "pycore_bitutils.h" // _Py_bswap64() #include "structmember.h" // PyMemberDef #include "hashlib.h" -#include "pystrhex.h" /*[clinic input] module _sha512 diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 1ab9621b1f2656..33950dc7749147 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -6,7 +6,6 @@ #include "pycore_bytes_methods.h" #include "pycore_object.h" #include "bytesobject.h" -#include "pystrhex.h" /*[clinic input] class bytearray "PyByteArrayObject *" "&PyByteArray_Type" diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index eaedb0b5689b2a..2ab7afe029242f 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -10,7 +10,6 @@ #include "pycore_object.h" // _PyObject_GC_TRACK #include "pycore_pymem.h" // PYMEM_CLEANBYTE -#include "pystrhex.h" #include /*[clinic input] diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index d328f4d40b7a42..01929acc70edaf 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -13,7 +13,6 @@ #include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_object.h" -#include "pystrhex.h" #include /*[clinic input] diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 536a8bf5267009..2cdcf0de49bba2 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -153,6 +153,7 @@ + @@ -242,7 +243,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 23f4579a9cf615..7bbac3f4993dfc 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -204,9 +204,6 @@ Include - - Include - Include @@ -450,6 +447,9 @@ Include\cpython + + Include + Include\cpython diff --git a/Python/pystrhex.c b/Python/pystrhex.c index b74e57ad913b11..9b0da921f3dd20 100644 --- a/Python/pystrhex.c +++ b/Python/pystrhex.c @@ -2,8 +2,6 @@ #include "Python.h" -#include "pystrhex.h" - static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen, const PyObject* sep, int bytes_per_sep_group, const int return_bytes) From d316147f643382deb54d2dba9ef0e821c350aa6d Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 13:16:05 +0800 Subject: [PATCH 3/8] Move Include/symtable.h to Include/cpython/symtable.h --- Include/Python.h | 1 + Include/{ => cpython}/symtable.h | 0 Makefile.pre.in | 2 +- Modules/symtablemodule.c | 1 - PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 6 +++--- Python/compile.c | 1 - Python/future.c | 1 - Python/pythonrun.c | 1 - Python/symtable.c | 1 - Tools/scripts/stable_abi.py | 1 - 11 files changed, 6 insertions(+), 11 deletions(-) rename Include/{ => cpython}/symtable.h (100%) diff --git a/Include/Python.h b/Include/Python.h index ec996411c7c937..fb8d836d8e1160 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -162,5 +162,6 @@ #include "cpython/pyfpe.h" #include "tracemalloc.h" #include "cpython/asdl.h" +#include "cpython/symtable.h" #endif /* !Py_PYTHON_H */ diff --git a/Include/symtable.h b/Include/cpython/symtable.h similarity index 100% rename from Include/symtable.h rename to Include/cpython/symtable.h diff --git a/Makefile.pre.in b/Makefile.pre.in index cc647bf5c21c46..e92678e6296b03 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1080,7 +1080,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/sliceobject.h \ $(srcdir)/Include/structmember.h \ $(srcdir)/Include/structseq.h \ - $(srcdir)/Include/symtable.h \ $(srcdir)/Include/sysmodule.h \ $(srcdir)/Include/token.h \ $(srcdir)/Include/traceback.h \ @@ -1124,6 +1123,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/pystrhex.h \ $(srcdir)/Include/cpython/pythonrun.h \ $(srcdir)/Include/cpython/pytime.h \ + $(srcdir)/Include/cpython/symtable.h \ $(srcdir)/Include/cpython/sysmodule.h \ $(srcdir)/Include/cpython/traceback.h \ $(srcdir)/Include/cpython/tupleobject.h \ diff --git a/Modules/symtablemodule.c b/Modules/symtablemodule.c index f6c378fdaedc1d..419edcc0e01806 100644 --- a/Modules/symtablemodule.c +++ b/Modules/symtablemodule.c @@ -2,7 +2,6 @@ #include "code.h" #include "Python-ast.h" -#include "symtable.h" #include "clinic/symtablemodule.c.h" /*[clinic input] diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 2cdcf0de49bba2..b7dd9d299d9894 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -156,6 +156,7 @@ + @@ -251,7 +252,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 7bbac3f4993dfc..e8f2f2eef4cc48 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -231,9 +231,6 @@ Include - - Include - Include @@ -468,6 +465,9 @@ Include\cpython + + Include + Include\cpython diff --git a/Python/compile.c b/Python/compile.c index b0d3127ff6878f..1a2c244338a580 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -28,7 +28,6 @@ #include "Python-ast.h" #include "ast.h" #include "code.h" -#include "symtable.h" #define NEED_OPCODE_JUMP_TABLES #include "opcode.h" #include "wordcode_helpers.h" diff --git a/Python/future.c b/Python/future.c index 4b73eb64129052..05f4449f107306 100644 --- a/Python/future.c +++ b/Python/future.c @@ -2,7 +2,6 @@ #include "Python-ast.h" #include "token.h" #include "code.h" -#include "symtable.h" #include "ast.h" #define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined" diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 338a1b96d39e1b..78dee4b7704676 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -23,7 +23,6 @@ #include "token.h" // INDENT #include "errcode.h" // E_EOF #include "code.h" // PyCodeObject -#include "symtable.h" // PySymtable_BuildObject() #include "marshal.h" // PyMarshal_ReadLongFromFile() #ifdef MS_WINDOWS diff --git a/Python/symtable.c b/Python/symtable.c index 10a47d1215e665..7899fe0f80daa0 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1,6 +1,5 @@ #include "Python.h" #include "pycore_pystate.h" // _PyThreadState_GET() -#include "symtable.h" #undef Yield /* undefine macro conflicting with */ #include "structmember.h" // PyMemberDef diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py index cc1009da1bde25..0f9e36547e765d 100755 --- a/Tools/scripts/stable_abi.py +++ b/Tools/scripts/stable_abi.py @@ -24,7 +24,6 @@ "parsetok.h", "pyatomic.h", "pytime.h", - "symtable.h", "token.h", "ucnhash.h", } From 360fa6ad53f6676e61867a16b5dd42f04137b732 Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 13:17:24 +0800 Subject: [PATCH 4/8] Move Include/token.h to Include/cpython/token.h --- Include/{ => cpython}/token.h | 0 Makefile.pre.in | 6 +++--- PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 6 +++--- PCbuild/regen.vcxproj | 6 +++--- Parser/pegen.h | 2 +- Parser/token.c | 2 +- Parser/tokenizer.h | 2 +- Python/future.c | 2 +- Python/pythonrun.c | 2 +- Tools/scripts/generate_token.py | 6 +++--- Tools/scripts/stable_abi.py | 1 - 12 files changed, 18 insertions(+), 19 deletions(-) rename Include/{ => cpython}/token.h (100%) diff --git a/Include/token.h b/Include/cpython/token.h similarity index 100% rename from Include/token.h rename to Include/cpython/token.h diff --git a/Makefile.pre.in b/Makefile.pre.in index e92678e6296b03..808d3547457c40 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -882,11 +882,11 @@ regen-token: $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py rst \ $(srcdir)/Grammar/Tokens \ $(srcdir)/Doc/library/token-list.inc - # Regenerate Include/token.h from Grammar/Tokens + # Regenerate Include/cpython/token.h from Grammar/Tokens # using Tools/scripts/generate_token.py $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py h \ $(srcdir)/Grammar/Tokens \ - $(srcdir)/Include/token.h + $(srcdir)/Include/cpython/token.h # Regenerate Parser/token.c from Grammar/Tokens # using Tools/scripts/generate_token.py $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_token.py c \ @@ -1081,7 +1081,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/structmember.h \ $(srcdir)/Include/structseq.h \ $(srcdir)/Include/sysmodule.h \ - $(srcdir)/Include/token.h \ $(srcdir)/Include/traceback.h \ $(srcdir)/Include/tracemalloc.h \ $(srcdir)/Include/tupleobject.h \ @@ -1125,6 +1124,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/pytime.h \ $(srcdir)/Include/cpython/symtable.h \ $(srcdir)/Include/cpython/sysmodule.h \ + $(srcdir)/Include/cpython/token.h \ $(srcdir)/Include/cpython/traceback.h \ $(srcdir)/Include/cpython/tupleobject.h \ $(srcdir)/Include/cpython/unicodeobject.h \ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index b7dd9d299d9894..76d352d60a4f47 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -158,6 +158,7 @@ + @@ -253,7 +254,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index e8f2f2eef4cc48..80dfe3f412bf85 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -234,9 +234,6 @@ Include - - Include - Include @@ -471,6 +468,9 @@ Include\cpython + + Include + Include\cpython diff --git a/PCbuild/regen.vcxproj b/PCbuild/regen.vcxproj index 936f5fd24646a5..3f9564aa6e0901 100644 --- a/PCbuild/regen.vcxproj +++ b/PCbuild/regen.vcxproj @@ -133,7 +133,7 @@ - + @@ -187,8 +187,8 @@ - - + + diff --git a/Parser/pegen.h b/Parser/pegen.h index 3765b2425fff7e..11f64b6a51c757 100644 --- a/Parser/pegen.h +++ b/Parser/pegen.h @@ -3,7 +3,7 @@ #define PY_SSIZE_T_CLEAN #include -#include +#include #include #if 0 diff --git a/Parser/token.c b/Parser/token.c index a489668900901d..ff532286a79732 100644 --- a/Parser/token.c +++ b/Parser/token.c @@ -1,7 +1,7 @@ /* Auto-generated by Tools/scripts/generate_token.py */ #include "Python.h" -#include "token.h" +#include "cpython/token.h" /* Token names */ diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h index 56074b61ae100e..16a7416be52f6a 100644 --- a/Parser/tokenizer.h +++ b/Parser/tokenizer.h @@ -8,7 +8,7 @@ extern "C" { /* Tokenizer interface */ -#include "token.h" /* For token types */ +#include "cpython/token.h" /* For token types */ #define MAXINDENT 100 /* Max indentation level */ #define MAXLEVEL 200 /* Max parentheses level */ diff --git a/Python/future.c b/Python/future.c index 05f4449f107306..b7f80f0a589b00 100644 --- a/Python/future.c +++ b/Python/future.c @@ -1,6 +1,6 @@ #include "Python.h" #include "Python-ast.h" -#include "token.h" +#include "cpython/token.h" #include "code.h" #include "ast.h" diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 78dee4b7704676..95b23fb06b0502 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -20,7 +20,7 @@ #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_sysmodule.h" // _PySys_Audit() -#include "token.h" // INDENT +#include "cpython/token.h" // INDENT #include "errcode.h" // E_EOF #include "code.h" // PyCodeObject #include "marshal.h" // PyMarshal_ReadLongFromFile() diff --git a/Tools/scripts/generate_token.py b/Tools/scripts/generate_token.py index 77bb5bd5eca02c..ee5660906282ad 100755 --- a/Tools/scripts/generate_token.py +++ b/Tools/scripts/generate_token.py @@ -2,7 +2,7 @@ # This script generates token related files from Grammar/Tokens: # # Doc/library/token-list.inc -# Include/token.h +# Include/cpython/token.h # Parser/token.c # Lib/token.py @@ -87,7 +87,7 @@ def update_file(file, content): #endif /* Py_LIMITED_API */ """ -def make_h(infile, outfile='Include/token.h'): +def make_h(infile, outfile='Include/cpython/token.h'): tok_names, ERRORTOKEN, string_to_tok = load_tokens(infile) defines = [] @@ -106,7 +106,7 @@ def make_h(infile, outfile='Include/token.h'): /* Auto-generated by Tools/scripts/generate_token.py */ #include "Python.h" -#include "token.h" +#include "cpython/token.h" /* Token names */ diff --git a/Tools/scripts/stable_abi.py b/Tools/scripts/stable_abi.py index 0f9e36547e765d..19585d8ac870c2 100755 --- a/Tools/scripts/stable_abi.py +++ b/Tools/scripts/stable_abi.py @@ -24,7 +24,6 @@ "parsetok.h", "pyatomic.h", "pytime.h", - "token.h", "ucnhash.h", } From efdc86fd32e1ed42e690f7b1fc221182daa69e41 Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 13:17:46 +0800 Subject: [PATCH 5/8] Move Include/tracemalloc.h to Include/cpython/tracemalloc.h --- Include/Python.h | 2 +- Include/{ => cpython}/tracemalloc.h | 0 Makefile.pre.in | 2 +- PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 6 +++--- 5 files changed, 6 insertions(+), 6 deletions(-) rename Include/{ => cpython}/tracemalloc.h (100%) diff --git a/Include/Python.h b/Include/Python.h index fb8d836d8e1160..ee700317e087ef 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -160,7 +160,7 @@ #include "cpython/pystrhex.h" #include "fileutils.h" #include "cpython/pyfpe.h" -#include "tracemalloc.h" +#include "cpython/tracemalloc.h" #include "cpython/asdl.h" #include "cpython/symtable.h" diff --git a/Include/tracemalloc.h b/Include/cpython/tracemalloc.h similarity index 100% rename from Include/tracemalloc.h rename to Include/cpython/tracemalloc.h diff --git a/Makefile.pre.in b/Makefile.pre.in index 808d3547457c40..c4ac0ddd83a643 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1082,7 +1082,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/structseq.h \ $(srcdir)/Include/sysmodule.h \ $(srcdir)/Include/traceback.h \ - $(srcdir)/Include/tracemalloc.h \ $(srcdir)/Include/tupleobject.h \ $(srcdir)/Include/unicodeobject.h \ $(srcdir)/Include/warnings.h \ @@ -1126,6 +1125,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/sysmodule.h \ $(srcdir)/Include/cpython/token.h \ $(srcdir)/Include/cpython/traceback.h \ + $(srcdir)/Include/cpython/tracemalloc.h \ $(srcdir)/Include/cpython/tupleobject.h \ $(srcdir)/Include/cpython/unicodeobject.h \ \ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 76d352d60a4f47..40272d9600e6b8 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -160,6 +160,7 @@ + @@ -255,7 +256,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 80dfe3f412bf85..4a70730881252e 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -237,9 +237,6 @@ Include - - Include - Include @@ -471,6 +468,9 @@ Include + + Include + Include\cpython From e37970eaf05ad483d91d131bf67112ae62a7f50c Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 13:22:26 +0800 Subject: [PATCH 6/8] update news and whatsnew --- Doc/whatsnew/3.10.rst | 11 ++++++----- .../C API/2021-03-06-13-22-18.bpo-35134.X92fuH.rst | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2021-03-06-13-22-18.bpo-35134.X92fuH.rst diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index db71f061f14df4..deace4f64116b3 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1252,13 +1252,14 @@ Porting to Python 3.10 bugs like ``if (PyList_SET_ITEM (a, b, c) < 0) ...`` test. (Contributed by Zackery Spytz and Victor Stinner in :issue:`30459`.) -* The non-limited API files ``odictobject.h``, ``parser_interface.h``, - ``picklebufobject.h``, ``pyarena.h``, ``pyctype.h``, ``pydebug.h``, - ``pyfpe.h``, and ``pytime.h`` have been moved to the ``Include/cpython`` +* The non-limited API files ``asdl.h``, ``odictobject.h``, + ``parser_interface.h``, ``picklebufobject.h``, ``pyarena.h``, ``pyctype.h``, + ``pydebug.h``, ``pyfpe.h``, ``pystrhex.h``, ``pytime.h``, ``symtable.h``, + ``token.h``, and ``tracemalloc.h`` have been moved to the ``Include/cpython`` directory. These files must not be included directly, as they are already included in ``Python.h``: :ref:`Include Files `. If they have - been included directly, consider including ``Python.h`` instead. - (Contributed by Nicholas Sim in :issue:`35134`) + been included directly, consider including ``Python.h`` instead. (Contributed + by Nicholas Sim in :issue:`35134`) Deprecated ---------- diff --git a/Misc/NEWS.d/next/C API/2021-03-06-13-22-18.bpo-35134.X92fuH.rst b/Misc/NEWS.d/next/C API/2021-03-06-13-22-18.bpo-35134.X92fuH.rst new file mode 100644 index 00000000000000..54220ae133b7cb --- /dev/null +++ b/Misc/NEWS.d/next/C API/2021-03-06-13-22-18.bpo-35134.X92fuH.rst @@ -0,0 +1,3 @@ +Move asdl.h, pystrhex.h, symtable.h, token.h, and tracemalloc.h into the +cpython/ directory. They must not be included directly, as they are already +included by Python.h: :ref:`Include Files `. From 5fab3a43ec1f8a764f3ab6a08feef1438b1aa659 Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 15:21:58 +0800 Subject: [PATCH 7/8] Python-ast: don't include Python.h at beginning Undoes previous change in this PR which breaks on Windows due to the Yield macro in winbase.h --- Include/Python-ast.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/Python-ast.h b/Include/Python-ast.h index dcbd6b43ac51f8..c48a56e644184f 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef Py_LIMITED_API -#include "Python.h" +#include "cpython/asdl.h" #undef Yield /* undefine macro conflicting with */ From e95d1fe417a0c32e8f7c1b27f7f5fb3e92704475 Mon Sep 17 00:00:00 2001 From: Nicholas Sim Date: Sat, 6 Mar 2021 15:27:14 +0800 Subject: [PATCH 8/8] Python-ast: don't include Python.h at beginning Neglected to stage this change --- Parser/asdl_c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 4b03fc7b221fa1..4a1c1d25c02e24 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1498,7 +1498,7 @@ def write_header(mod, f): f.write('#endif\n') f.write('\n') f.write('#ifndef Py_LIMITED_API\n') - f.write('#include "Python.h"\n') + f.write('#include "cpython/asdl.h"\n') f.write('\n') f.write('#undef Yield /* undefine macro conflicting with */\n') f.write('\n')