mirror of https://github.com/python/cpython
bpo-43244: Remove the PyAST_Validate() function (GH-24911)
Remove the PyAST_Validate() function. It is no longer possible to
build a AST object (mod_ty type) with the public C API. The function
was already excluded from the limited C API (PEP 384).
Rename PyAST_Validate() function to _PyAST_Validate(), move it to the
internal C API, and don't export it anymore (replace PyAPI_FUNC with
extern).
The function was added in bpo-12575 by
the commit 832bfe2ebd
.
This commit is contained in:
parent
fc980e0be1
commit
eec8e61992
|
@ -1353,3 +1353,8 @@ Removed
|
||||||
Python already implicitly installs signal handlers: see
|
Python already implicitly installs signal handlers: see
|
||||||
:c:member:`PyConfig.install_signal_handlers`.
|
:c:member:`PyConfig.install_signal_handlers`.
|
||||||
(Contributed by Victor Stinner in :issue:`41713`.)
|
(Contributed by Victor Stinner in :issue:`41713`.)
|
||||||
|
|
||||||
|
* Remove the ``PyAST_Validate()`` function. It is no longer possible to build a
|
||||||
|
AST object (``mod_ty`` type) with the public C API. The function was already
|
||||||
|
excluded from the limited C API (:pep:`384`).
|
||||||
|
(Contributed by Victor Stinner in :issue:`43244`.)
|
||||||
|
|
|
@ -7,8 +7,6 @@ extern "C" {
|
||||||
|
|
||||||
#include "Python-ast.h" /* mod_ty */
|
#include "Python-ast.h" /* mod_ty */
|
||||||
|
|
||||||
PyAPI_FUNC(int) PyAST_Validate(mod_ty);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,6 +10,8 @@ extern "C" {
|
||||||
|
|
||||||
#include "Python-ast.h" // expr_ty
|
#include "Python-ast.h" // expr_ty
|
||||||
|
|
||||||
|
extern int _PyAST_Validate(mod_ty);
|
||||||
|
|
||||||
/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
|
/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
|
||||||
extern PyObject* _PyAST_ExprAsUnicode(expr_ty);
|
extern PyObject* _PyAST_ExprAsUnicode(expr_ty);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Remove the ``PyAST_Validate()`` function. It is no longer possible to build a
|
||||||
|
AST object (``mod_ty`` type) with the public C API. The function was already
|
||||||
|
excluded from the limited C API (:pep:`384`). Patch by Victor Stinner.
|
|
@ -1,4 +1,5 @@
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
#include "pycore_ast.h" // _PyAST_Validate()
|
||||||
#include <errcode.h>
|
#include <errcode.h>
|
||||||
#include "tokenizer.h"
|
#include "tokenizer.h"
|
||||||
|
|
||||||
|
@ -1271,7 +1272,7 @@ _PyPegen_run_parser(Parser *p)
|
||||||
p->start_rule == Py_file_input ||
|
p->start_rule == Py_file_input ||
|
||||||
p->start_rule == Py_eval_input)
|
p->start_rule == Py_eval_input)
|
||||||
{
|
{
|
||||||
if (!PyAST_Validate(res)) {
|
if (!_PyAST_Validate(res)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -551,7 +551,7 @@ validate_exprs(asdl_expr_seq *exprs, expr_context_ty ctx, int null_ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyAST_Validate(mod_ty mod)
|
_PyAST_Validate(mod_ty mod)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
#undef Yield /* undefine macro conflicting with <winbase.h> */
|
#undef Yield /* undefine macro conflicting with <winbase.h> */
|
||||||
|
#include "pycore_ast.h" // _PyAST_Validate()
|
||||||
#include "pycore_object.h" // _Py_AddToAllObjects()
|
#include "pycore_object.h" // _Py_AddToAllObjects()
|
||||||
#include "pycore_pyerrors.h" // _PyErr_NoMemory()
|
#include "pycore_pyerrors.h" // _PyErr_NoMemory()
|
||||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||||
|
@ -835,7 +836,7 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
|
||||||
PyArena_Free(arena);
|
PyArena_Free(arena);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!PyAST_Validate(mod)) {
|
if (!_PyAST_Validate(mod)) {
|
||||||
PyArena_Free(arena);
|
PyArena_Free(arena);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue