summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorBatuhan Taskaya <batuhanosmantaskaya@gmail.com>2020-10-10 17:14:59 (GMT)
committerGitHub <noreply@github.com>2020-10-10 17:14:59 (GMT)
commit02a1603f918b9862e164e4fd050c505b16bc9f57 (patch)
tree89edf08ba59a6f30fd436375b7c24ce5402b71d0 /Python/ast.c
parent637a09b0d6e3ad4e34e0b5e0fc82f5afeae6f74b (diff)
downloadcpython-02a1603f918b9862e164e4fd050c505b16bc9f57.zip
cpython-02a1603f918b9862e164e4fd050c505b16bc9f57.tar.gz
cpython-02a1603f918b9862e164e4fd050c505b16bc9f57.tar.bz2
bpo-42000: Cleanup the AST related C-code (GH-22641)
- Use the proper asdl sequence when creating empty arguments - Remove reduntant casts (thanks to new typed asdl_sequences) - Remove MarshalPrototypeVisitor and some utilities from asdl generator - Fix the header of `Python/ast.c` (kept from pgen times) Automerge-Triggered-By: @pablogsal
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 4b7bbd2..5e74f65 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1,18 +1,12 @@
/*
- * This file includes functions to transform a concrete syntax tree (CST) to
- * an abstract syntax tree (AST). The main function is PyAST_FromNode().
- *
+ * This file exposes PyAST_Validate interface to check the integrity
+ * of the given abstract syntax tree (potentially constructed manually).
*/
#include "Python.h"
#include "Python-ast.h"
#include "ast.h"
-#include "token.h"
-#include "pythonrun.h"
#include <assert.h>
-#include <stdbool.h>
-
-#define MAXLEVEL 200 /* Max parentheses level */
static int validate_stmts(asdl_stmt_seq *);
static int validate_exprs(asdl_expr_seq*, expr_context_ty, int);
@@ -62,7 +56,7 @@ validate_keywords(asdl_keyword_seq *keywords)
{
Py_ssize_t i;
for (i = 0; i < asdl_seq_LEN(keywords); i++)
- if (!validate_expr(((keyword_ty)asdl_seq_GET(keywords, i))->value, Load))
+ if (!validate_expr((asdl_seq_GET(keywords, i))->value, Load))
return 0;
return 1;
}
@@ -556,7 +550,7 @@ _PyAST_GetDocString(asdl_stmt_seq *body)
if (!asdl_seq_LEN(body)) {
return NULL;
}
- stmt_ty st = (stmt_ty)asdl_seq_GET(body, 0);
+ stmt_ty st = asdl_seq_GET(body, 0);
if (st->kind != Expr_kind) {
return NULL;
}