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/Include/Python-ast.h b/Include/Python-ast.h index bd127ca2ab0cad..c48a56e644184f 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 "cpython/asdl.h" #undef Yield /* undefine macro conflicting with */ diff --git a/Include/Python.h b/Include/Python.h index 86dbbcf6bd85da..ee700317e087ef 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -157,8 +157,11 @@ #include "cpython/pyctype.h" #include "pystrtod.h" #include "pystrcmp.h" +#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" #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/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/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/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/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 0f59700952989e..c4ac0ddd83a643 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 \ @@ -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 \ @@ -1073,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 \ @@ -1082,11 +1080,8 @@ 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 \ - $(srcdir)/Include/tracemalloc.h \ $(srcdir)/Include/tupleobject.h \ $(srcdir)/Include/unicodeobject.h \ $(srcdir)/Include/warnings.h \ @@ -1097,6 +1092,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 \ @@ -1122,10 +1118,14 @@ 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/symtable.h \ $(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/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 `. 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/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/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 92355a886d91a7..40272d9600e6b8 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -113,7 +113,6 @@ - @@ -127,6 +126,7 @@ + @@ -153,10 +153,14 @@ + + + + @@ -242,7 +246,6 @@ - @@ -251,11 +254,8 @@ - - - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index d0b69dbc5b64fd..4a70730881252e 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -42,9 +42,6 @@ Include - - Include - Include @@ -207,9 +204,6 @@ Include - - Include - Include @@ -237,21 +231,12 @@ Include - - Include - Include - - Include - Include - - Include - Include @@ -381,6 +366,9 @@ Include\cpython + + Include + Include\cpython @@ -450,6 +438,9 @@ Include\cpython + + Include + Include\cpython @@ -468,9 +459,18 @@ Include\cpython + + Include + Include\cpython + + Include + + + 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/asdl_c.py b/Parser/asdl_c.py index 8c167bc79c779b..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 "asdl.h"\n') + f.write('#include "cpython/asdl.h"\n') f.write('\n') f.write('#undef Yield /* undefine macro conflicting with */\n') f.write('\n') 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/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*); 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..b7f80f0a589b00 100644 --- a/Python/future.c +++ b/Python/future.c @@ -1,8 +1,7 @@ #include "Python.h" #include "Python-ast.h" -#include "token.h" +#include "cpython/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/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) diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 338a1b96d39e1b..95b23fb06b0502 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -20,10 +20,9 @@ #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 "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/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 cc1009da1bde25..19585d8ac870c2 100755 --- a/Tools/scripts/stable_abi.py +++ b/Tools/scripts/stable_abi.py @@ -24,8 +24,6 @@ "parsetok.h", "pyatomic.h", "pytime.h", - "symtable.h", - "token.h", "ucnhash.h", }