From 94faa0724f8cbae6867c491c8e465e35f4fdbfbb Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 23 Mar 2021 20:47:40 +0100 Subject: bpo-43244: Remove ast.h, asdl.h, Python-ast.h headers (GH-24933) These functions were undocumented and excluded from the limited C API. Most names defined by these header files were not prefixed by "Py" and so could create names conflicts. For example, Python-ast.h defined a "Yield" macro which was conflict with the "Yield" name used by the Windows header. Use the Python ast module instead. * Move Include/asdl.h to Include/internal/pycore_asdl.h. * Move Include/Python-ast.h to Include/internal/pycore_ast.h. * Remove ast.h header file. * pycore_symtable.h no longer includes Python-ast.h. --- Python/Python-ast.c | 4 ++-- Python/asdl.c | 2 +- Python/ast.c | 3 +-- Python/ast_unparse.c | 6 +++--- Python/bltinmodule.c | 3 +-- Python/import.c | 1 - Python/pylifecycle.c | 3 --- Python/pythonrun.c | 2 +- Python/symtable.c | 1 + 9 files changed, 10 insertions(+), 15 deletions(-) (limited to 'Python') diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 4524877dd4..63c214dba1 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -24,9 +24,9 @@ get_ast_state(void) return state; } -// Include Python-ast.h after pycore_interp.h to avoid conflicts +// Include pycore_ast.h after pycore_interp.h to avoid conflicts // with the Yield macro redefined by -#include "Python-ast.h" +#include "pycore_ast.h" #include "structmember.h" void _PyAST_Fini(PyInterpreterState *interp) diff --git a/Python/asdl.c b/Python/asdl.c index 4ff07e4377..a7f2180c88 100644 --- a/Python/asdl.c +++ b/Python/asdl.c @@ -1,5 +1,5 @@ #include "Python.h" -#include "asdl.h" +#include "pycore_asdl.h" GENERATE_ASDL_SEQ_CONSTRUCTOR(generic, void*); GENERATE_ASDL_SEQ_CONSTRUCTOR(identifier, PyObject*); diff --git a/Python/ast.c b/Python/ast.c index 8ac2e60c92..c87795305e 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -3,8 +3,7 @@ * of the given abstract syntax tree (potentially constructed manually). */ #include "Python.h" -#include "Python-ast.h" -#include "ast.h" +#include "pycore_ast.h" // asdl_stmt_seq #include diff --git a/Python/ast_unparse.c b/Python/ast_unparse.c index a04ff93e9d..5276b2fcd6 100644 --- a/Python/ast_unparse.c +++ b/Python/ast_unparse.c @@ -1,7 +1,7 @@ -#include /* DBL_MAX_10_EXP */ -#include #include "Python.h" -#include "Python-ast.h" +#include "pycore_ast.h" // expr_ty +#include // DBL_MAX_10_EXP +#include static PyObject *_str_open_br; static PyObject *_str_dbl_open_br; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 9f83c036d0..c3f7e39eb6 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2,9 +2,8 @@ #include "Python.h" #include -#include "ast.h" -#undef Yield /* undefine macro conflicting with */ #include "pycore_ast.h" // _PyAST_Validate() +#undef Yield /* undefine macro conflicting with */ #include "pycore_object.h" // _Py_AddToAllObjects() #include "pycore_pyerrors.h" // _PyErr_NoMemory() #include "pycore_pystate.h" // _PyThreadState_GET() diff --git a/Python/import.c b/Python/import.c index b898a2bd92..6fba057bad 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2,7 +2,6 @@ #include "Python.h" -#include "Python-ast.h" #undef Yield /* undefine macro conflicting with */ #include "pycore_import.h" // _PyImport_BootstrapImp() #include "pycore_initconfig.h" diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 1b8c435736..8309477806 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2,9 +2,6 @@ #include "Python.h" -#include "Python-ast.h" -#undef Yield /* undefine macro conflicting with */ - #include "pycore_ceval.h" // _PyEval_FiniGIL() #include "pycore_context.h" // _PyContext_Init() #include "pycore_fileutils.h" // _Py_ResetForceASCII() diff --git a/Python/pythonrun.c b/Python/pythonrun.c index adb43e75f9..02fd8b0b8b 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -10,7 +10,7 @@ #include "Python.h" -#include "Python-ast.h" +#include "pycore_ast.h" // PyAST_mod2obj #undef Yield /* undefine macro conflicting with */ #include "pycore_interp.h" // PyInterpreterState.importlib diff --git a/Python/symtable.c b/Python/symtable.c index 85648f21e6..78874404ad 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "pycore_ast.h" // identifier, stmt_ty #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_symtable.h" // PySTEntryObject #undef Yield /* undefine macro conflicting with */ -- cgit v1.2.1