From 6689c60108a7e6655045fa4447fceedf7650e9d9 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Mon, 1 Mar 2021 00:49:34 +0800 Subject: [PATCH] move pyarena.h from include/cpython to include/internal --- Doc/whatsnew/3.10.rst | 4 ++++ Include/Python-ast.h | 1 + Include/Python.h | 1 - Include/compile.h | 2 ++ Include/{cpython/pyarena.h => internal/pycore_arena.h} | 0 Makefile.pre.in | 2 +- .../next/C API/2021-03-02-01-31-58.bpo-43244.SuTGYi.rst | 2 ++ PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 6 +++--- Parser/asdl_c.py | 3 +++ Python/Python-ast.c | 2 ++ Python/bltinmodule.c | 1 + Python/compile.c | 1 + Python/pythonrun.c | 1 + Tools/peg_generator/peg_extension/peg_extension.c | 1 + 15 files changed, 23 insertions(+), 6 deletions(-) rename Include/{cpython/pyarena.h => internal/pycore_arena.h} (100%) create mode 100644 Misc/NEWS.d/next/C API/2021-03-02-01-31-58.bpo-43244.SuTGYi.rst diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 310554eabe6706..078c87eb55fd91 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -957,6 +957,10 @@ Porting to Python 3.10 been included directly, consider including ``Python.h`` instead. (Contributed by Nicholas Sim in :issue:`35134`) +* The non-limited API file ``pyarena.h`` has been moved to the + ``Include/internal/pycore_arena.h``. + (Contributed by Hai Shi in :issue:`43244`.) + Deprecated ---------- diff --git a/Include/Python-ast.h b/Include/Python-ast.h index bd127ca2ab0cad..dbfbea58d264a7 100644 --- a/Include/Python-ast.h +++ b/Include/Python-ast.h @@ -8,6 +8,7 @@ extern "C" { #ifndef Py_LIMITED_API #include "asdl.h" +#include "pycore_arena.h" #undef Yield /* undefine macro conflicting with */ diff --git a/Include/Python.h b/Include/Python.h index 86dbbcf6bd85da..e3e1486c656192 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -137,7 +137,6 @@ #include "pystate.h" #include "context.h" -#include "cpython/pyarena.h" #include "modsupport.h" #include "compile.h" #include "pythonrun.h" diff --git a/Include/compile.h b/Include/compile.h index 4dd5435ce71a96..d01301311acc3f 100644 --- a/Include/compile.h +++ b/Include/compile.h @@ -7,6 +7,8 @@ extern "C" { #endif +#include "internal/pycore_arena.h" // struct PyArena + /* Public interface */ #define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ diff --git a/Include/cpython/pyarena.h b/Include/internal/pycore_arena.h similarity index 100% rename from Include/cpython/pyarena.h rename to Include/internal/pycore_arena.h diff --git a/Makefile.pre.in b/Makefile.pre.in index 0f59700952989e..24156f07bbbe56 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1114,7 +1114,6 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/objimpl.h \ $(srcdir)/Include/cpython/odictobject.h \ $(srcdir)/Include/cpython/picklebufobject.h \ - $(srcdir)/Include/cpython/pyarena.h \ $(srcdir)/Include/cpython/pyctype.h \ $(srcdir)/Include/cpython/pydebug.h \ $(srcdir)/Include/cpython/pyerrors.h \ @@ -1129,6 +1128,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/cpython/tupleobject.h \ $(srcdir)/Include/cpython/unicodeobject.h \ \ + $(srcdir)/Include/internal/pycore_arena.h \ $(srcdir)/Include/internal/pycore_abstract.h \ $(srcdir)/Include/internal/pycore_accu.h \ $(srcdir)/Include/internal/pycore_atomic.h \ diff --git a/Misc/NEWS.d/next/C API/2021-03-02-01-31-58.bpo-43244.SuTGYi.rst b/Misc/NEWS.d/next/C API/2021-03-02-01-31-58.bpo-43244.SuTGYi.rst new file mode 100644 index 00000000000000..7837f217291634 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2021-03-02-01-31-58.bpo-43244.SuTGYi.rst @@ -0,0 +1,2 @@ +The non-limited API file ``pyarena.h`` has been moved to the +``Include/internal/pycore_arena.h``. diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 92355a886d91a7..93f3c191429fac 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -145,7 +145,6 @@ - @@ -173,6 +172,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index d0b69dbc5b64fd..c65b000689865e 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -429,9 +429,6 @@ Include - - Include - Include @@ -477,6 +474,9 @@ Include\cpython + + Include\internal + Include\internal diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 8c167bc79c779b..46fe83c52d6e1b 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1499,6 +1499,7 @@ def write_header(mod, f): f.write('\n') f.write('#ifndef Py_LIMITED_API\n') f.write('#include "asdl.h"\n') + f.write('#include "pycore_arena.h"\n') f.write('\n') f.write('#undef Yield /* undefine macro conflicting with */\n') f.write('\n') @@ -1549,6 +1550,8 @@ def write_source(mod, f, internal_h_file): #include #include "Python.h" + + #include "pycore_arena.h" """), file=f) generate_module_def(mod, f, internal_h_file) diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 439da8f2512ef2..3f35b001f5f06c 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -5,6 +5,8 @@ #include "Python.h" +#include "pycore_arena.h" + #ifdef Py_BUILD_CORE # include "pycore_ast.h" // struct ast_state # include "pycore_interp.h" // _PyInterpreterState.ast diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index dec2984a068df2..750ea21c64adb3 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -4,6 +4,7 @@ #include #include "ast.h" #undef Yield /* undefine macro conflicting with */ +#include "pycore_arena.h" // struct PyArena #include "pycore_object.h" // _Py_AddToAllObjects() #include "pycore_pyerrors.h" // _PyErr_NoMemory() #include "pycore_pystate.h" // _PyThreadState_GET() diff --git a/Python/compile.c b/Python/compile.c index 454005eb7b0cbe..1585bc7333b8df 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -22,6 +22,7 @@ */ #include "Python.h" +#include "pycore_arena.h" // struct PyArena #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_long.h" // _PyLong_GetZero() diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 338a1b96d39e1b..2ff1bdfd39bde7 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -13,6 +13,7 @@ #include "Python-ast.h" #undef Yield /* undefine macro conflicting with */ +#include "pycore_arena.h" // struct PyArena #include "pycore_interp.h" // PyInterpreterState.importlib #include "pycore_object.h" // _PyDebug_PrintTotalRefs() #include "pycore_pyerrors.h" // _PyErr_Fetch diff --git a/Tools/peg_generator/peg_extension/peg_extension.c b/Tools/peg_generator/peg_extension/peg_extension.c index 96d3a52b880880..16d321090dd338 100644 --- a/Tools/peg_generator/peg_extension/peg_extension.c +++ b/Tools/peg_generator/peg_extension/peg_extension.c @@ -1,4 +1,5 @@ #include "pegen.h" +#include "pycore_arena.h" //struct PyArena PyObject * _build_return_object(mod_ty module, int mode, PyObject *filename_ob, PyArena *arena)