bpo-43244: Remove the PyAST_Validate() function (GH-24911) · devdanzin/cpython@eec8e61 · GitHub
Skip to content

Commit eec8e61

Browse files
authored
bpo-43244: Remove the PyAST_Validate() function (pythonGH-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 832bfe2.
1 parent fc980e0 commit eec8e61

7 files changed

Lines changed: 15 additions & 5 deletions

File tree

Doc/whatsnew/3.10.rst

Lines changed: 5 additions & 0 deletions

Include/ast.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ extern "C" {
77

88
#include "Python-ast.h" /* mod_ty */
99

10-
PyAPI_FUNC(int) PyAST_Validate(mod_ty);
11-
1210
#ifdef __cplusplus
1311
}
1412
#endif

Include/internal/pycore_ast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern "C" {
1010

1111
#include "Python-ast.h" // expr_ty
1212

13+
extern int _PyAST_Validate(mod_ty);
14+
1315
/* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
1416
extern PyObject* _PyAST_ExprAsUnicode(expr_ty);
1517

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the ``PyAST_Validate()`` function. It is no longer possible to build a
2+
AST object (``mod_ty`` type) with the public C API. The function was already
3+
excluded from the limited C API (:pep:`384`). Patch by Victor Stinner.

Parser/pegen.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <Python.h>
2+
#include "pycore_ast.h" // _PyAST_Validate()
23
#include <errcode.h>
34
#include "tokenizer.h"
45

@@ -1271,7 +1272,7 @@ _PyPegen_run_parser(Parser *p)
12711272
p->start_rule == Py_file_input ||
12721273
p->start_rule == Py_eval_input)
12731274
{
1274-
if (!PyAST_Validate(res)) {
1275+
if (!_PyAST_Validate(res)) {
12751276
return NULL;
12761277
}
12771278
}

Python/ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ validate_exprs(asdl_expr_seq *exprs, expr_context_ty ctx, int null_ok)
551551
}
552552

553553
int
554-
PyAST_Validate(mod_ty mod)
554+
_PyAST_Validate(mod_ty mod)
555555
{
556556
int res = 0;
557557

Python/bltinmodule.c

Lines changed: 2 additions & 1 deletion

0 commit comments

Comments
 (0)