aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/Python-ast.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-04-18 12:39:32 +0300
committershadchin <shadchin@yandex-team.ru>2022-04-18 12:39:32 +0300
commitd4be68e361f4258cf0848fc70018dfe37a2acc24 (patch)
tree153e294cd97ac8b5d7a989612704a0c1f58e8ad4 /contrib/tools/python3/src/Python/Python-ast.c
parent260c02f5ccf242d9d9b8a873afaf6588c00237d6 (diff)
downloadydb-d4be68e361f4258cf0848fc70018dfe37a2acc24.tar.gz
IGNIETFERRO-1816 Update Python 3 from 3.9.12 to 3.10.4
ref:9f96be6d02ee8044fdd6f124b799b270c20ce641
Diffstat (limited to 'contrib/tools/python3/src/Python/Python-ast.c')
-rw-r--r--contrib/tools/python3/src/Python/Python-ast.c3291
1 files changed, 2247 insertions, 1044 deletions
diff --git a/contrib/tools/python3/src/Python/Python-ast.c b/contrib/tools/python3/src/Python/Python-ast.c
index 8b1c594a87..2f84cad774 100644
--- a/contrib/tools/python3/src/Python/Python-ast.c
+++ b/contrib/tools/python3/src/Python/Python-ast.c
@@ -1,258 +1,31 @@
-/* File automatically generated by Parser/asdl_c.py. */
-
-#include <stddef.h>
+// File automatically generated by Parser/asdl_c.py.
#include "Python.h"
-#include "Python-ast.h"
-#include "structmember.h" // PyMemberDef
-
-typedef struct {
- int initialized;
- PyObject *AST_type;
- PyObject *Add_singleton;
- PyObject *Add_type;
- PyObject *And_singleton;
- PyObject *And_type;
- PyObject *AnnAssign_type;
- PyObject *Assert_type;
- PyObject *Assign_type;
- PyObject *AsyncFor_type;
- PyObject *AsyncFunctionDef_type;
- PyObject *AsyncWith_type;
- PyObject *Attribute_type;
- PyObject *AugAssign_type;
- PyObject *Await_type;
- PyObject *BinOp_type;
- PyObject *BitAnd_singleton;
- PyObject *BitAnd_type;
- PyObject *BitOr_singleton;
- PyObject *BitOr_type;
- PyObject *BitXor_singleton;
- PyObject *BitXor_type;
- PyObject *BoolOp_type;
- PyObject *Break_type;
- PyObject *Call_type;
- PyObject *ClassDef_type;
- PyObject *Compare_type;
- PyObject *Constant_type;
- PyObject *Continue_type;
- PyObject *Del_singleton;
- PyObject *Del_type;
- PyObject *Delete_type;
- PyObject *DictComp_type;
- PyObject *Dict_type;
- PyObject *Div_singleton;
- PyObject *Div_type;
- PyObject *Eq_singleton;
- PyObject *Eq_type;
- PyObject *ExceptHandler_type;
- PyObject *Expr_type;
- PyObject *Expression_type;
- PyObject *FloorDiv_singleton;
- PyObject *FloorDiv_type;
- PyObject *For_type;
- PyObject *FormattedValue_type;
- PyObject *FunctionDef_type;
- PyObject *FunctionType_type;
- PyObject *GeneratorExp_type;
- PyObject *Global_type;
- PyObject *GtE_singleton;
- PyObject *GtE_type;
- PyObject *Gt_singleton;
- PyObject *Gt_type;
- PyObject *IfExp_type;
- PyObject *If_type;
- PyObject *ImportFrom_type;
- PyObject *Import_type;
- PyObject *In_singleton;
- PyObject *In_type;
- PyObject *Interactive_type;
- PyObject *Invert_singleton;
- PyObject *Invert_type;
- PyObject *IsNot_singleton;
- PyObject *IsNot_type;
- PyObject *Is_singleton;
- PyObject *Is_type;
- PyObject *JoinedStr_type;
- PyObject *LShift_singleton;
- PyObject *LShift_type;
- PyObject *Lambda_type;
- PyObject *ListComp_type;
- PyObject *List_type;
- PyObject *Load_singleton;
- PyObject *Load_type;
- PyObject *LtE_singleton;
- PyObject *LtE_type;
- PyObject *Lt_singleton;
- PyObject *Lt_type;
- PyObject *MatMult_singleton;
- PyObject *MatMult_type;
- PyObject *Mod_singleton;
- PyObject *Mod_type;
- PyObject *Module_type;
- PyObject *Mult_singleton;
- PyObject *Mult_type;
- PyObject *Name_type;
- PyObject *NamedExpr_type;
- PyObject *Nonlocal_type;
- PyObject *NotEq_singleton;
- PyObject *NotEq_type;
- PyObject *NotIn_singleton;
- PyObject *NotIn_type;
- PyObject *Not_singleton;
- PyObject *Not_type;
- PyObject *Or_singleton;
- PyObject *Or_type;
- PyObject *Pass_type;
- PyObject *Pow_singleton;
- PyObject *Pow_type;
- PyObject *RShift_singleton;
- PyObject *RShift_type;
- PyObject *Raise_type;
- PyObject *Return_type;
- PyObject *SetComp_type;
- PyObject *Set_type;
- PyObject *Slice_type;
- PyObject *Starred_type;
- PyObject *Store_singleton;
- PyObject *Store_type;
- PyObject *Sub_singleton;
- PyObject *Sub_type;
- PyObject *Subscript_type;
- PyObject *Try_type;
- PyObject *Tuple_type;
- PyObject *TypeIgnore_type;
- PyObject *UAdd_singleton;
- PyObject *UAdd_type;
- PyObject *USub_singleton;
- PyObject *USub_type;
- PyObject *UnaryOp_type;
- PyObject *While_type;
- PyObject *With_type;
- PyObject *YieldFrom_type;
- PyObject *Yield_type;
- PyObject *__dict__;
- PyObject *__doc__;
- PyObject *__module__;
- PyObject *_attributes;
- PyObject *_fields;
- PyObject *alias_type;
- PyObject *annotation;
- PyObject *arg;
- PyObject *arg_type;
- PyObject *args;
- PyObject *argtypes;
- PyObject *arguments_type;
- PyObject *asname;
- PyObject *ast;
- PyObject *attr;
- PyObject *bases;
- PyObject *body;
- PyObject *boolop_type;
- PyObject *cause;
- PyObject *cmpop_type;
- PyObject *col_offset;
- PyObject *comparators;
- PyObject *comprehension_type;
- PyObject *context_expr;
- PyObject *conversion;
- PyObject *ctx;
- PyObject *decorator_list;
- PyObject *defaults;
- PyObject *elt;
- PyObject *elts;
- PyObject *end_col_offset;
- PyObject *end_lineno;
- PyObject *exc;
- PyObject *excepthandler_type;
- PyObject *expr_context_type;
- PyObject *expr_type;
- PyObject *finalbody;
- PyObject *format_spec;
- PyObject *func;
- PyObject *generators;
- PyObject *handlers;
- PyObject *id;
- PyObject *ifs;
- PyObject *is_async;
- PyObject *items;
- PyObject *iter;
- PyObject *key;
- PyObject *keys;
- PyObject *keyword_type;
- PyObject *keywords;
- PyObject *kind;
- PyObject *kw_defaults;
- PyObject *kwarg;
- PyObject *kwonlyargs;
- PyObject *left;
- PyObject *level;
- PyObject *lineno;
- PyObject *lower;
- PyObject *mod_type;
- PyObject *module;
- PyObject *msg;
- PyObject *name;
- PyObject *names;
- PyObject *op;
- PyObject *operand;
- PyObject *operator_type;
- PyObject *ops;
- PyObject *optional_vars;
- PyObject *orelse;
- PyObject *posonlyargs;
- PyObject *returns;
- PyObject *right;
- PyObject *simple;
- PyObject *slice;
- PyObject *step;
- PyObject *stmt_type;
- PyObject *tag;
- PyObject *target;
- PyObject *targets;
- PyObject *test;
- PyObject *type;
- PyObject *type_comment;
- PyObject *type_ignore_type;
- PyObject *type_ignores;
- PyObject *unaryop_type;
- PyObject *upper;
- PyObject *value;
- PyObject *values;
- PyObject *vararg;
- PyObject *withitem_type;
-} astmodulestate;
-
+#include "pycore_ast.h"
+#include "pycore_ast_state.h" // struct ast_state
+#include "pycore_interp.h" // _PyInterpreterState.ast
+#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "structmember.h"
+#include <stddef.h>
// Forward declaration
-static int init_types(astmodulestate *state);
+static int init_types(struct ast_state *state);
-// bpo-41194, bpo-41261, bpo-41631: The _ast module uses a global state.
-static astmodulestate global_ast_state = {0};
-
-static astmodulestate*
-get_global_ast_state(void)
+static struct ast_state*
+get_ast_state(void)
{
- astmodulestate* state = &global_ast_state;
+ PyInterpreterState *interp = _PyInterpreterState_GET();
+ struct ast_state *state = &interp->ast;
if (!init_types(state)) {
return NULL;
}
return state;
}
-static astmodulestate*
-get_ast_state(PyObject* Py_UNUSED(module))
+void _PyAST_Fini(PyInterpreterState *interp)
{
- astmodulestate* state = get_global_ast_state();
- // get_ast_state() must only be called after _ast module is imported,
- // and astmodule_exec() calls init_types()
- assert(state != NULL);
- return state;
-}
+ struct ast_state *state = &interp->ast;
-void _PyAST_Fini()
-{
- astmodulestate* state = &global_ast_state;
Py_CLEAR(state->AST_type);
Py_CLEAR(state->Add_singleton);
Py_CLEAR(state->Add_type);
@@ -332,6 +105,15 @@ void _PyAST_Fini()
Py_CLEAR(state->Lt_type);
Py_CLEAR(state->MatMult_singleton);
Py_CLEAR(state->MatMult_type);
+ Py_CLEAR(state->MatchAs_type);
+ Py_CLEAR(state->MatchClass_type);
+ Py_CLEAR(state->MatchMapping_type);
+ Py_CLEAR(state->MatchOr_type);
+ Py_CLEAR(state->MatchSequence_type);
+ Py_CLEAR(state->MatchSingleton_type);
+ Py_CLEAR(state->MatchStar_type);
+ Py_CLEAR(state->MatchValue_type);
+ Py_CLEAR(state->Match_type);
Py_CLEAR(state->Mod_singleton);
Py_CLEAR(state->Mod_type);
Py_CLEAR(state->Module_type);
@@ -378,6 +160,7 @@ void _PyAST_Fini()
Py_CLEAR(state->Yield_type);
Py_CLEAR(state->__dict__);
Py_CLEAR(state->__doc__);
+ Py_CLEAR(state->__match_args__);
Py_CLEAR(state->__module__);
Py_CLEAR(state->_attributes);
Py_CLEAR(state->_fields);
@@ -394,7 +177,9 @@ void _PyAST_Fini()
Py_CLEAR(state->bases);
Py_CLEAR(state->body);
Py_CLEAR(state->boolop_type);
+ Py_CLEAR(state->cases);
Py_CLEAR(state->cause);
+ Py_CLEAR(state->cls);
Py_CLEAR(state->cmpop_type);
Py_CLEAR(state->col_offset);
Py_CLEAR(state->comparators);
@@ -416,6 +201,7 @@ void _PyAST_Fini()
Py_CLEAR(state->format_spec);
Py_CLEAR(state->func);
Py_CLEAR(state->generators);
+ Py_CLEAR(state->guard);
Py_CLEAR(state->handlers);
Py_CLEAR(state->id);
Py_CLEAR(state->ifs);
@@ -429,11 +215,14 @@ void _PyAST_Fini()
Py_CLEAR(state->kind);
Py_CLEAR(state->kw_defaults);
Py_CLEAR(state->kwarg);
+ Py_CLEAR(state->kwd_attrs);
+ Py_CLEAR(state->kwd_patterns);
Py_CLEAR(state->kwonlyargs);
Py_CLEAR(state->left);
Py_CLEAR(state->level);
Py_CLEAR(state->lineno);
Py_CLEAR(state->lower);
+ Py_CLEAR(state->match_case_type);
Py_CLEAR(state->mod_type);
Py_CLEAR(state->module);
Py_CLEAR(state->msg);
@@ -445,13 +234,18 @@ void _PyAST_Fini()
Py_CLEAR(state->ops);
Py_CLEAR(state->optional_vars);
Py_CLEAR(state->orelse);
+ Py_CLEAR(state->pattern);
+ Py_CLEAR(state->pattern_type);
+ Py_CLEAR(state->patterns);
Py_CLEAR(state->posonlyargs);
+ Py_CLEAR(state->rest);
Py_CLEAR(state->returns);
Py_CLEAR(state->right);
Py_CLEAR(state->simple);
Py_CLEAR(state->slice);
Py_CLEAR(state->step);
Py_CLEAR(state->stmt_type);
+ Py_CLEAR(state->subject);
Py_CLEAR(state->tag);
Py_CLEAR(state->target);
Py_CLEAR(state->targets);
@@ -467,13 +261,18 @@ void _PyAST_Fini()
Py_CLEAR(state->vararg);
Py_CLEAR(state->withitem_type);
+#if !defined(NDEBUG)
+ state->initialized = -1;
+#else
state->initialized = 0;
+#endif
}
-static int init_identifiers(astmodulestate *state)
+static int init_identifiers(struct ast_state *state)
{
if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return 0;
if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return 0;
+ if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return 0;
if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return 0;
if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return 0;
if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return 0;
@@ -486,7 +285,9 @@ static int init_identifiers(astmodulestate *state)
if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0;
if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0;
if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0;
+ if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0;
if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0;
+ if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return 0;
if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return 0;
if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return 0;
if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return 0;
@@ -503,6 +304,7 @@ static int init_identifiers(astmodulestate *state)
if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return 0;
if ((state->func = PyUnicode_InternFromString("func")) == NULL) return 0;
if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return 0;
+ if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return 0;
if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return 0;
if ((state->id = PyUnicode_InternFromString("id")) == NULL) return 0;
if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return 0;
@@ -515,6 +317,8 @@ static int init_identifiers(astmodulestate *state)
if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return 0;
if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return 0;
if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return 0;
+ if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return 0;
+ if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return 0;
if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return 0;
if ((state->left = PyUnicode_InternFromString("left")) == NULL) return 0;
if ((state->level = PyUnicode_InternFromString("level")) == NULL) return 0;
@@ -529,12 +333,16 @@ static int init_identifiers(astmodulestate *state)
if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return 0;
if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return 0;
if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return 0;
+ if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return 0;
+ if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return 0;
if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return 0;
+ if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return 0;
if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return 0;
if ((state->right = PyUnicode_InternFromString("right")) == NULL) return 0;
if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return 0;
if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return 0;
if ((state->step = PyUnicode_InternFromString("step")) == NULL) return 0;
+ if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return 0;
if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return 0;
if ((state->target = PyUnicode_InternFromString("target")) == NULL) return 0;
if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return 0;
@@ -549,7 +357,21 @@ static int init_identifiers(astmodulestate *state)
return 1;
};
-static PyObject* ast2obj_mod(astmodulestate *state, void*);
+GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
+GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
+
+static PyObject* ast2obj_mod(struct ast_state *state, void*);
static const char * const Module_fields[]={
"body",
"type_ignores",
@@ -570,7 +392,7 @@ static const char * const stmt_attributes[] = {
"end_lineno",
"end_col_offset",
};
-static PyObject* ast2obj_stmt(astmodulestate *state, void*);
+static PyObject* ast2obj_stmt(struct ast_state *state, void*);
static const char * const FunctionDef_fields[]={
"name",
"args",
@@ -650,6 +472,10 @@ static const char * const AsyncWith_fields[]={
"body",
"type_comment",
};
+static const char * const Match_fields[]={
+ "subject",
+ "cases",
+};
static const char * const Raise_fields[]={
"exc",
"cause",
@@ -687,7 +513,7 @@ static const char * const expr_attributes[] = {
"end_lineno",
"end_col_offset",
};
-static PyObject* ast2obj_expr(astmodulestate *state, void*);
+static PyObject* ast2obj_expr(struct ast_state *state, void*);
static const char * const BoolOp_fields[]={
"op",
"values",
@@ -800,12 +626,12 @@ static const char * const Slice_fields[]={
"upper",
"step",
};
-static PyObject* ast2obj_expr_context(astmodulestate *state, expr_context_ty);
-static PyObject* ast2obj_boolop(astmodulestate *state, boolop_ty);
-static PyObject* ast2obj_operator(astmodulestate *state, operator_ty);
-static PyObject* ast2obj_unaryop(astmodulestate *state, unaryop_ty);
-static PyObject* ast2obj_cmpop(astmodulestate *state, cmpop_ty);
-static PyObject* ast2obj_comprehension(astmodulestate *state, void*);
+static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
+static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
+static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
+static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
+static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
+static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
static const char * const comprehension_fields[]={
"target",
"iter",
@@ -818,13 +644,13 @@ static const char * const excepthandler_attributes[] = {
"end_lineno",
"end_col_offset",
};
-static PyObject* ast2obj_excepthandler(astmodulestate *state, void*);
+static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
static const char * const ExceptHandler_fields[]={
"type",
"name",
"body",
};
-static PyObject* ast2obj_arguments(astmodulestate *state, void*);
+static PyObject* ast2obj_arguments(struct ast_state *state, void*);
static const char * const arguments_fields[]={
"posonlyargs",
"args",
@@ -834,7 +660,7 @@ static const char * const arguments_fields[]={
"kwarg",
"defaults",
};
-static PyObject* ast2obj_arg(astmodulestate *state, void*);
+static PyObject* ast2obj_arg(struct ast_state *state, void*);
static const char * const arg_attributes[] = {
"lineno",
"col_offset",
@@ -846,7 +672,7 @@ static const char * const arg_fields[]={
"annotation",
"type_comment",
};
-static PyObject* ast2obj_keyword(astmodulestate *state, void*);
+static PyObject* ast2obj_keyword(struct ast_state *state, void*);
static const char * const keyword_attributes[] = {
"lineno",
"col_offset",
@@ -857,17 +683,66 @@ static const char * const keyword_fields[]={
"arg",
"value",
};
-static PyObject* ast2obj_alias(astmodulestate *state, void*);
+static PyObject* ast2obj_alias(struct ast_state *state, void*);
+static const char * const alias_attributes[] = {
+ "lineno",
+ "col_offset",
+ "end_lineno",
+ "end_col_offset",
+};
static const char * const alias_fields[]={
"name",
"asname",
};
-static PyObject* ast2obj_withitem(astmodulestate *state, void*);
+static PyObject* ast2obj_withitem(struct ast_state *state, void*);
static const char * const withitem_fields[]={
"context_expr",
"optional_vars",
};
-static PyObject* ast2obj_type_ignore(astmodulestate *state, void*);
+static PyObject* ast2obj_match_case(struct ast_state *state, void*);
+static const char * const match_case_fields[]={
+ "pattern",
+ "guard",
+ "body",
+};
+static const char * const pattern_attributes[] = {
+ "lineno",
+ "col_offset",
+ "end_lineno",
+ "end_col_offset",
+};
+static PyObject* ast2obj_pattern(struct ast_state *state, void*);
+static const char * const MatchValue_fields[]={
+ "value",
+};
+static const char * const MatchSingleton_fields[]={
+ "value",
+};
+static const char * const MatchSequence_fields[]={
+ "patterns",
+};
+static const char * const MatchMapping_fields[]={
+ "keys",
+ "patterns",
+ "rest",
+};
+static const char * const MatchClass_fields[]={
+ "cls",
+ "patterns",
+ "kwd_attrs",
+ "kwd_patterns",
+};
+static const char * const MatchStar_fields[]={
+ "name",
+};
+static const char * const MatchAs_fields[]={
+ "pattern",
+ "name",
+};
+static const char * const MatchOr_fields[]={
+ "patterns",
+};
+static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
static const char * const TypeIgnore_fields[]={
"lineno",
"tag",
@@ -911,7 +786,7 @@ ast_clear(AST_object *self)
static int
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
{
- astmodulestate *state = get_global_ast_state();
+ struct ast_state *state = get_ast_state();
if (state == NULL) {
return -1;
}
@@ -987,7 +862,7 @@ ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
static PyObject *
ast_type_reduce(PyObject *self, PyObject *unused)
{
- astmodulestate *state = get_global_ast_state();
+ struct ast_state *state = get_ast_state();
if (state == NULL) {
return NULL;
}
@@ -1042,7 +917,7 @@ static PyType_Spec AST_type_spec = {
};
static PyObject *
-make_type(astmodulestate *state, const char *type, PyObject* base,
+make_type(struct ast_state *state, const char *type, PyObject* base,
const char* const* fields, int num_fields, const char *doc)
{
PyObject *fnames, *result;
@@ -1057,9 +932,10 @@ make_type(astmodulestate *state, const char *type, PyObject* base,
}
PyTuple_SET_ITEM(fnames, i, field);
}
- result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOs}",
+ result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
type, base,
state->_fields, fnames,
+ state->__match_args__, fnames,
state->__module__,
state->ast,
state->__doc__, doc);
@@ -1068,7 +944,7 @@ make_type(astmodulestate *state, const char *type, PyObject* base,
}
static int
-add_attributes(astmodulestate *state, PyObject *type, const char * const *attrs, int num_fields)
+add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
{
int i, result;
PyObject *s, *l = PyTuple_New(num_fields);
@@ -1089,7 +965,7 @@ add_attributes(astmodulestate *state, PyObject *type, const char * const *attrs,
/* Conversion AST -> Python */
-static PyObject* ast2obj_list(astmodulestate *state, asdl_seq *seq, PyObject* (*func)(astmodulestate *state, void*))
+static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq, PyObject* (*func)(struct ast_state *state, void*))
{
Py_ssize_t i, n = asdl_seq_LEN(seq);
PyObject *result = PyList_New(n);
@@ -1097,7 +973,7 @@ static PyObject* ast2obj_list(astmodulestate *state, asdl_seq *seq, PyObject* (*
if (!result)
return NULL;
for (i = 0; i < n; i++) {
- value = func(state, asdl_seq_GET(seq, i));
+ value = func(state, asdl_seq_GET_UNTYPED(seq, i));
if (!value) {
Py_DECREF(result);
return NULL;
@@ -1107,7 +983,7 @@ static PyObject* ast2obj_list(astmodulestate *state, asdl_seq *seq, PyObject* (*
return result;
}
-static PyObject* ast2obj_object(astmodulestate *Py_UNUSED(state), void *o)
+static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
{
if (!o)
o = Py_None;
@@ -1118,19 +994,19 @@ static PyObject* ast2obj_object(astmodulestate *Py_UNUSED(state), void *o)
#define ast2obj_identifier ast2obj_object
#define ast2obj_string ast2obj_object
-static PyObject* ast2obj_int(astmodulestate *Py_UNUSED(state), long b)
+static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
{
return PyLong_FromLong(b);
}
/* Conversion Python -> AST */
-static int obj2ast_object(astmodulestate *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
+static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
{
if (obj == Py_None)
obj = NULL;
if (obj) {
- if (PyArena_AddPyObject(arena, obj) < 0) {
+ if (_PyArena_AddPyObject(arena, obj) < 0) {
*out = NULL;
return -1;
}
@@ -1140,9 +1016,9 @@ static int obj2ast_object(astmodulestate *Py_UNUSED(state), PyObject* obj, PyObj
return 0;
}
-static int obj2ast_constant(astmodulestate *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
+static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
{
- if (PyArena_AddPyObject(arena, obj) < 0) {
+ if (_PyArena_AddPyObject(arena, obj) < 0) {
*out = NULL;
return -1;
}
@@ -1151,7 +1027,7 @@ static int obj2ast_constant(astmodulestate *Py_UNUSED(state), PyObject* obj, PyO
return 0;
}
-static int obj2ast_identifier(astmodulestate *state, PyObject* obj, PyObject** out, PyArena* arena)
+static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
{
if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
@@ -1160,7 +1036,7 @@ static int obj2ast_identifier(astmodulestate *state, PyObject* obj, PyObject** o
return obj2ast_object(state, obj, out, arena);
}
-static int obj2ast_string(astmodulestate *state, PyObject* obj, PyObject** out, PyArena* arena)
+static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
{
if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
@@ -1169,7 +1045,7 @@ static int obj2ast_string(astmodulestate *state, PyObject* obj, PyObject** out,
return obj2ast_object(state, obj, out, arena);
}
-static int obj2ast_int(astmodulestate* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
+static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
{
int i;
if (!PyLong_Check(obj)) {
@@ -1184,12 +1060,13 @@ static int obj2ast_int(astmodulestate* Py_UNUSED(state), PyObject* obj, int* out
return 0;
}
-static int add_ast_fields(astmodulestate *state)
+static int add_ast_fields(struct ast_state *state)
{
PyObject *empty_tuple;
empty_tuple = PyTuple_New(0);
if (!empty_tuple ||
PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
+ PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
Py_XDECREF(empty_tuple);
return -1;
@@ -1199,13 +1076,27 @@ static int add_ast_fields(astmodulestate *state)
}
-static int init_types(astmodulestate *state)
+
+static int
+init_types(struct ast_state *state)
{
- if (state->initialized) return 1;
- if (init_identifiers(state) < 0) return 0;
+ // init_types() must not be called after _PyAST_Fini()
+ // has been called
+ assert(state->initialized >= 0);
+
+ if (state->initialized) {
+ return 1;
+ }
+ if (init_identifiers(state) < 0) {
+ return 0;
+ }
state->AST_type = PyType_FromSpec(&AST_type_spec);
- if (!state->AST_type) return 0;
- if (add_ast_fields(state) < 0) return 0;
+ if (!state->AST_type) {
+ return 0;
+ }
+ if (add_ast_fields(state) < 0) {
+ return 0;
+ }
state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
"mod = Module(stmt* body, type_ignore* type_ignores)\n"
" | Interactive(stmt* body)\n"
@@ -1245,6 +1136,7 @@ static int init_types(astmodulestate *state)
" | If(expr test, stmt* body, stmt* orelse)\n"
" | With(withitem* items, stmt* body, string? type_comment)\n"
" | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
+ " | Match(expr subject, match_case* cases)\n"
" | Raise(expr? exc, expr? cause)\n"
" | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
" | Assert(expr test, expr? msg)\n"
@@ -1347,6 +1239,10 @@ static int init_types(astmodulestate *state)
if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
== -1)
return 0;
+ state->Match_type = make_type(state, "Match", state->stmt_type,
+ Match_fields, 2,
+ "Match(expr subject, match_case* cases)");
+ if (!state->Match_type) return 0;
state->Raise_type = make_type(state, "Raise", state->stmt_type,
Raise_fields, 2,
"Raise(expr? exc, expr? cause)");
@@ -1416,7 +1312,7 @@ static int init_types(astmodulestate *state)
" | YieldFrom(expr value)\n"
" | Compare(expr left, cmpop* ops, expr* comparators)\n"
" | Call(expr func, expr* args, keyword* keywords)\n"
- " | FormattedValue(expr value, int? conversion, expr? format_spec)\n"
+ " | FormattedValue(expr value, int conversion, expr? format_spec)\n"
" | JoinedStr(expr* values)\n"
" | Constant(constant value, string? kind)\n"
" | Attribute(expr value, identifier attr, expr_context ctx)\n"
@@ -1506,11 +1402,8 @@ static int init_types(astmodulestate *state)
state->FormattedValue_type = make_type(state, "FormattedValue",
state->expr_type,
FormattedValue_fields, 3,
- "FormattedValue(expr value, int? conversion, expr? format_spec)");
+ "FormattedValue(expr value, int conversion, expr? format_spec)");
if (!state->FormattedValue_type) return 0;
- if (PyObject_SetAttr(state->FormattedValue_type, state->conversion,
- Py_None) == -1)
- return 0;
if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
Py_None) == -1)
return 0;
@@ -1853,9 +1746,15 @@ static int init_types(astmodulestate *state)
alias_fields, 2,
"alias(identifier name, identifier? asname)");
if (!state->alias_type) return 0;
- if (!add_attributes(state, state->alias_type, NULL, 0)) return 0;
+ if (!add_attributes(state, state->alias_type, alias_attributes, 4)) return
+ 0;
if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
return 0;
+ if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
+ return 0;
+ if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
+ -1)
+ return 0;
state->withitem_type = make_type(state, "withitem", state->AST_type,
withitem_fields, 2,
"withitem(expr context_expr, expr? optional_vars)");
@@ -1864,6 +1763,70 @@ static int init_types(astmodulestate *state)
if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
== -1)
return 0;
+ state->match_case_type = make_type(state, "match_case", state->AST_type,
+ match_case_fields, 3,
+ "match_case(pattern pattern, expr? guard, stmt* body)");
+ if (!state->match_case_type) return 0;
+ if (!add_attributes(state, state->match_case_type, NULL, 0)) return 0;
+ if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
+ return 0;
+ state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
+ "pattern = MatchValue(expr value)\n"
+ " | MatchSingleton(constant value)\n"
+ " | MatchSequence(pattern* patterns)\n"
+ " | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
+ " | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
+ " | MatchStar(identifier? name)\n"
+ " | MatchAs(pattern? pattern, identifier? name)\n"
+ " | MatchOr(pattern* patterns)");
+ if (!state->pattern_type) return 0;
+ if (!add_attributes(state, state->pattern_type, pattern_attributes, 4))
+ return 0;
+ state->MatchValue_type = make_type(state, "MatchValue",
+ state->pattern_type, MatchValue_fields,
+ 1,
+ "MatchValue(expr value)");
+ if (!state->MatchValue_type) return 0;
+ state->MatchSingleton_type = make_type(state, "MatchSingleton",
+ state->pattern_type,
+ MatchSingleton_fields, 1,
+ "MatchSingleton(constant value)");
+ if (!state->MatchSingleton_type) return 0;
+ state->MatchSequence_type = make_type(state, "MatchSequence",
+ state->pattern_type,
+ MatchSequence_fields, 1,
+ "MatchSequence(pattern* patterns)");
+ if (!state->MatchSequence_type) return 0;
+ state->MatchMapping_type = make_type(state, "MatchMapping",
+ state->pattern_type,
+ MatchMapping_fields, 3,
+ "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
+ if (!state->MatchMapping_type) return 0;
+ if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
+ return 0;
+ state->MatchClass_type = make_type(state, "MatchClass",
+ state->pattern_type, MatchClass_fields,
+ 4,
+ "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
+ if (!state->MatchClass_type) return 0;
+ state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
+ MatchStar_fields, 1,
+ "MatchStar(identifier? name)");
+ if (!state->MatchStar_type) return 0;
+ if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
+ return 0;
+ state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
+ MatchAs_fields, 2,
+ "MatchAs(pattern? pattern, identifier? name)");
+ if (!state->MatchAs_type) return 0;
+ if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
+ return 0;
+ if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
+ return 0;
+ state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
+ MatchOr_fields, 1,
+ "MatchOr(pattern* patterns)");
+ if (!state->MatchOr_type) return 0;
state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
NULL, 0,
"type_ignore = TypeIgnore(int lineno, string tag)");
@@ -1874,48 +1837,54 @@ static int init_types(astmodulestate *state)
TypeIgnore_fields, 2,
"TypeIgnore(int lineno, string tag)");
if (!state->TypeIgnore_type) return 0;
+
state->initialized = 1;
return 1;
}
-static int obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out,
+static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
PyArena* arena);
-static int obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out,
+static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
PyArena* arena);
-static int obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out,
+static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
PyArena* arena);
-static int obj2ast_expr_context(astmodulestate *state, PyObject* obj,
+static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
expr_context_ty* out, PyArena* arena);
-static int obj2ast_boolop(astmodulestate *state, PyObject* obj, boolop_ty* out,
- PyArena* arena);
-static int obj2ast_operator(astmodulestate *state, PyObject* obj, operator_ty*
- out, PyArena* arena);
-static int obj2ast_unaryop(astmodulestate *state, PyObject* obj, unaryop_ty*
+static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
+ out, PyArena* arena);
+static int obj2ast_operator(struct ast_state *state, PyObject* obj,
+ operator_ty* out, PyArena* arena);
+static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
out, PyArena* arena);
-static int obj2ast_cmpop(astmodulestate *state, PyObject* obj, cmpop_ty* out,
+static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
PyArena* arena);
-static int obj2ast_comprehension(astmodulestate *state, PyObject* obj,
+static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
comprehension_ty* out, PyArena* arena);
-static int obj2ast_excepthandler(astmodulestate *state, PyObject* obj,
+static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
excepthandler_ty* out, PyArena* arena);
-static int obj2ast_arguments(astmodulestate *state, PyObject* obj,
+static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
arguments_ty* out, PyArena* arena);
-static int obj2ast_arg(astmodulestate *state, PyObject* obj, arg_ty* out,
+static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
PyArena* arena);
-static int obj2ast_keyword(astmodulestate *state, PyObject* obj, keyword_ty*
+static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
out, PyArena* arena);
-static int obj2ast_alias(astmodulestate *state, PyObject* obj, alias_ty* out,
+static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
PyArena* arena);
-static int obj2ast_withitem(astmodulestate *state, PyObject* obj, withitem_ty*
- out, PyArena* arena);
-static int obj2ast_type_ignore(astmodulestate *state, PyObject* obj,
+static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
+ withitem_ty* out, PyArena* arena);
+static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
+ match_case_ty* out, PyArena* arena);
+static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
+ out, PyArena* arena);
+static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
type_ignore_ty* out, PyArena* arena);
mod_ty
-Module(asdl_seq * body, asdl_seq * type_ignores, PyArena *arena)
+_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
+ PyArena *arena)
{
mod_ty p;
- p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Module_kind;
@@ -1925,10 +1894,10 @@ Module(asdl_seq * body, asdl_seq * type_ignores, PyArena *arena)
}
mod_ty
-Interactive(asdl_seq * body, PyArena *arena)
+_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
{
mod_ty p;
- p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Interactive_kind;
@@ -1937,7 +1906,7 @@ Interactive(asdl_seq * body, PyArena *arena)
}
mod_ty
-Expression(expr_ty body, PyArena *arena)
+_PyAST_Expression(expr_ty body, PyArena *arena)
{
mod_ty p;
if (!body) {
@@ -1945,7 +1914,7 @@ Expression(expr_ty body, PyArena *arena)
"field 'body' is required for Expression");
return NULL;
}
- p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Expression_kind;
@@ -1954,7 +1923,7 @@ Expression(expr_ty body, PyArena *arena)
}
mod_ty
-FunctionType(asdl_seq * argtypes, expr_ty returns, PyArena *arena)
+_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
{
mod_ty p;
if (!returns) {
@@ -1962,7 +1931,7 @@ FunctionType(asdl_seq * argtypes, expr_ty returns, PyArena *arena)
"field 'returns' is required for FunctionType");
return NULL;
}
- p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = FunctionType_kind;
@@ -1972,9 +1941,10 @@ FunctionType(asdl_seq * argtypes, expr_ty returns, PyArena *arena)
}
stmt_ty
-FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
- decorator_list, expr_ty returns, string type_comment, int lineno,
- int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
+ asdl_expr_seq * decorator_list, expr_ty returns, string
+ type_comment, int lineno, int col_offset, int end_lineno,
+ int end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!name) {
@@ -1987,7 +1957,7 @@ FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
"field 'args' is required for FunctionDef");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = FunctionDef_kind;
@@ -2005,10 +1975,10 @@ FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
}
stmt_ty
-AsyncFunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq
- * decorator_list, expr_ty returns, string type_comment, int
- lineno, int col_offset, int end_lineno, int end_col_offset,
- PyArena *arena)
+_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
+ body, asdl_expr_seq * decorator_list, expr_ty returns,
+ string type_comment, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!name) {
@@ -2021,7 +1991,7 @@ AsyncFunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq
"field 'args' is required for AsyncFunctionDef");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = AsyncFunctionDef_kind;
@@ -2039,9 +2009,10 @@ AsyncFunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq
}
stmt_ty
-ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, asdl_seq *
- body, asdl_seq * decorator_list, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
+ keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
+ int lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
if (!name) {
@@ -2049,7 +2020,7 @@ ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, asdl_seq *
"field 'name' is required for ClassDef");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = ClassDef_kind;
@@ -2066,11 +2037,11 @@ ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, asdl_seq *
}
stmt_ty
-Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Return_kind;
@@ -2083,11 +2054,11 @@ Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
}
stmt_ty
-Delete(asdl_seq * targets, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Delete_kind;
@@ -2100,8 +2071,9 @@ Delete(asdl_seq * targets, int lineno, int col_offset, int end_lineno, int
}
stmt_ty
-Assign(asdl_seq * targets, expr_ty value, string type_comment, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
+ lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
if (!value) {
@@ -2109,7 +2081,7 @@ Assign(asdl_seq * targets, expr_ty value, string type_comment, int lineno, int
"field 'value' is required for Assign");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Assign_kind;
@@ -2124,8 +2096,8 @@ Assign(asdl_seq * targets, expr_ty value, string type_comment, int lineno, int
}
stmt_ty
-AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!target) {
@@ -2143,7 +2115,7 @@ AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
"field 'value' is required for AugAssign");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = AugAssign_kind;
@@ -2158,9 +2130,9 @@ AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
}
stmt_ty
-AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple, int
- lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
- *arena)
+_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
+ int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!target) {
@@ -2173,7 +2145,7 @@ AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple, int
"field 'annotation' is required for AnnAssign");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = AnnAssign_kind;
@@ -2189,9 +2161,9 @@ AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple, int
}
stmt_ty
-For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, string
- type_comment, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
+ orelse, string type_comment, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!target) {
@@ -2204,7 +2176,7 @@ For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, string
"field 'iter' is required for For");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = For_kind;
@@ -2221,9 +2193,9 @@ For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, string
}
stmt_ty
-AsyncFor(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
- string type_comment, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
+ asdl_stmt_seq * orelse, string type_comment, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!target) {
@@ -2236,7 +2208,7 @@ AsyncFor(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
"field 'iter' is required for AsyncFor");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = AsyncFor_kind;
@@ -2253,8 +2225,9 @@ AsyncFor(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
}
stmt_ty
-While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
+ lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
if (!test) {
@@ -2262,7 +2235,7 @@ While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
"field 'test' is required for While");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = While_kind;
@@ -2277,8 +2250,9 @@ While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
}
stmt_ty
-If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
+ lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
+ *arena)
{
stmt_ty p;
if (!test) {
@@ -2286,7 +2260,7 @@ If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
"field 'test' is required for If");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = If_kind;
@@ -2301,11 +2275,12 @@ If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
}
stmt_ty
-With(asdl_seq * items, asdl_seq * body, string type_comment, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
+ type_comment, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = With_kind;
@@ -2320,11 +2295,12 @@ With(asdl_seq * items, asdl_seq * body, string type_comment, int lineno, int
}
stmt_ty
-AsyncWith(asdl_seq * items, asdl_seq * body, string type_comment, int lineno,
- int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
+ type_comment, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = AsyncWith_kind;
@@ -2339,11 +2315,34 @@ AsyncWith(asdl_seq * items, asdl_seq * body, string type_comment, int lineno,
}
stmt_ty
-Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int end_lineno,
- int end_col_offset, PyArena *arena)
+_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+{
+ stmt_ty p;
+ if (!subject) {
+ PyErr_SetString(PyExc_ValueError,
+ "field 'subject' is required for Match");
+ return NULL;
+ }
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = Match_kind;
+ p->v.Match.subject = subject;
+ p->v.Match.cases = cases;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+stmt_ty
+_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Raise_kind;
@@ -2357,12 +2356,12 @@ Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int end_lineno,
}
stmt_ty
-Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq *
- finalbody, int lineno, int col_offset, int end_lineno, int end_col_offset,
- PyArena *arena)
+_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
+ asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Try_kind;
@@ -2378,8 +2377,8 @@ Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, asdl_seq *
}
stmt_ty
-Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int end_lineno,
- int end_col_offset, PyArena *arena)
+_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!test) {
@@ -2387,7 +2386,7 @@ Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int end_lineno,
"field 'test' is required for Assert");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Assert_kind;
@@ -2401,11 +2400,11 @@ Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int end_lineno,
}
stmt_ty
-Import(asdl_seq * names, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Import_kind;
@@ -2418,11 +2417,12 @@ Import(asdl_seq * names, int lineno, int col_offset, int end_lineno, int
}
stmt_ty
-ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
+ lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = ImportFrom_kind;
@@ -2437,11 +2437,11 @@ ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int
}
stmt_ty
-Global(asdl_seq * names, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Global_kind;
@@ -2454,11 +2454,11 @@ Global(asdl_seq * names, int lineno, int col_offset, int end_lineno, int
}
stmt_ty
-Nonlocal(asdl_seq * names, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Nonlocal_kind;
@@ -2471,8 +2471,8 @@ Nonlocal(asdl_seq * names, int lineno, int col_offset, int end_lineno, int
}
stmt_ty
-Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
stmt_ty p;
if (!value) {
@@ -2480,7 +2480,7 @@ Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
"field 'value' is required for Expr");
return NULL;
}
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Expr_kind;
@@ -2493,11 +2493,11 @@ Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
}
stmt_ty
-Pass(int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
- *arena)
+_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Pass_kind;
@@ -2509,11 +2509,11 @@ Pass(int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
}
stmt_ty
-Break(int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
- *arena)
+_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Break_kind;
@@ -2525,11 +2525,11 @@ Break(int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
}
stmt_ty
-Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
- PyArena *arena)
+_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
stmt_ty p;
- p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Continue_kind;
@@ -2541,8 +2541,8 @@ Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
}
expr_ty
-BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
+ int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!op) {
@@ -2550,7 +2550,7 @@ BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, int
"field 'op' is required for BoolOp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = BoolOp_kind;
@@ -2564,8 +2564,8 @@ BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, int
}
expr_ty
-NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!target) {
@@ -2578,7 +2578,7 @@ NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
"field 'value' is required for NamedExpr");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = NamedExpr_kind;
@@ -2592,8 +2592,8 @@ NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
}
expr_ty
-BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
- int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!left) {
@@ -2611,7 +2611,7 @@ BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
"field 'right' is required for BinOp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = BinOp_kind;
@@ -2626,8 +2626,8 @@ BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
}
expr_ty
-UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!op) {
@@ -2640,7 +2640,7 @@ UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
"field 'operand' is required for UnaryOp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = UnaryOp_kind;
@@ -2654,8 +2654,8 @@ UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
}
expr_ty
-Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!args) {
@@ -2668,7 +2668,7 @@ Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
"field 'body' is required for Lambda");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Lambda_kind;
@@ -2682,8 +2682,8 @@ Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
}
expr_ty
-IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
- int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!test) {
@@ -2701,7 +2701,7 @@ IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
"field 'orelse' is required for IfExp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = IfExp_kind;
@@ -2716,11 +2716,11 @@ IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
}
expr_ty
-Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Dict_kind;
@@ -2734,11 +2734,11 @@ Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, int
}
expr_ty
-Set(asdl_seq * elts, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
+ int end_col_offset, PyArena *arena)
{
expr_ty p;
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Set_kind;
@@ -2751,8 +2751,9 @@ Set(asdl_seq * elts, int lineno, int col_offset, int end_lineno, int
}
expr_ty
-ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
+ int col_offset, int end_lineno, int end_col_offset, PyArena
+ *arena)
{
expr_ty p;
if (!elt) {
@@ -2760,7 +2761,7 @@ ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
"field 'elt' is required for ListComp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = ListComp_kind;
@@ -2774,8 +2775,9 @@ ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
}
expr_ty
-SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
+ int col_offset, int end_lineno, int end_col_offset, PyArena
+ *arena)
{
expr_ty p;
if (!elt) {
@@ -2783,7 +2785,7 @@ SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
"field 'elt' is required for SetComp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = SetComp_kind;
@@ -2797,8 +2799,9 @@ SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
}
expr_ty
-DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
+ generators, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
expr_ty p;
if (!key) {
@@ -2811,7 +2814,7 @@ DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
"field 'value' is required for DictComp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = DictComp_kind;
@@ -2826,8 +2829,9 @@ DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
}
expr_ty
-GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
- int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
+ lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
expr_ty p;
if (!elt) {
@@ -2835,7 +2839,7 @@ GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
"field 'elt' is required for GeneratorExp");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = GeneratorExp_kind;
@@ -2849,8 +2853,8 @@ GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
}
expr_ty
-Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
expr_ty p;
if (!value) {
@@ -2858,7 +2862,7 @@ Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
"field 'value' is required for Await");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Await_kind;
@@ -2871,11 +2875,11 @@ Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
}
expr_ty
-Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
expr_ty p;
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Yield_kind;
@@ -2888,8 +2892,8 @@ Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
}
expr_ty
-YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
expr_ty p;
if (!value) {
@@ -2897,7 +2901,7 @@ YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
"field 'value' is required for YieldFrom");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = YieldFrom_kind;
@@ -2910,8 +2914,9 @@ YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
}
expr_ty
-Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
- int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
+ int lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
expr_ty p;
if (!left) {
@@ -2919,7 +2924,7 @@ Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
"field 'left' is required for Compare");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Compare_kind;
@@ -2934,8 +2939,9 @@ Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
}
expr_ty
-Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
+ int lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
expr_ty p;
if (!func) {
@@ -2943,7 +2949,7 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int lineno, int
"field 'func' is required for Call");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Call_kind;
@@ -2958,9 +2964,9 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int lineno, int
}
expr_ty
-FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int lineno,
- int col_offset, int end_lineno, int end_col_offset, PyArena
- *arena)
+_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
+ lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
expr_ty p;
if (!value) {
@@ -2968,7 +2974,7 @@ FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int lineno,
"field 'value' is required for FormattedValue");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = FormattedValue_kind;
@@ -2983,11 +2989,11 @@ FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int lineno,
}
expr_ty
-JoinedStr(asdl_seq * values, int lineno, int col_offset, int end_lineno, int
- end_col_offset, PyArena *arena)
+_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = JoinedStr_kind;
@@ -3000,8 +3006,8 @@ JoinedStr(asdl_seq * values, int lineno, int col_offset, int end_lineno, int
}
expr_ty
-Constant(constant value, string kind, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!value) {
@@ -3009,7 +3015,7 @@ Constant(constant value, string kind, int lineno, int col_offset, int
"field 'value' is required for Constant");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Constant_kind;
@@ -3023,8 +3029,9 @@ Constant(constant value, string kind, int lineno, int col_offset, int
}
expr_ty
-Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
+ lineno, int col_offset, int end_lineno, int end_col_offset,
+ PyArena *arena)
{
expr_ty p;
if (!value) {
@@ -3042,7 +3049,7 @@ Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
"field 'ctx' is required for Attribute");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Attribute_kind;
@@ -3057,8 +3064,9 @@ Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
}
expr_ty
-Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
+ int col_offset, int end_lineno, int end_col_offset, PyArena
+ *arena)
{
expr_ty p;
if (!value) {
@@ -3076,7 +3084,7 @@ Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno, int
"field 'ctx' is required for Subscript");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Subscript_kind;
@@ -3091,8 +3099,8 @@ Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno, int
}
expr_ty
-Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
+ int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!value) {
@@ -3105,7 +3113,7 @@ Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, int
"field 'ctx' is required for Starred");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Starred_kind;
@@ -3119,8 +3127,8 @@ Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, int
}
expr_ty
-Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!id) {
@@ -3133,7 +3141,7 @@ Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
"field 'ctx' is required for Name");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Name_kind;
@@ -3147,8 +3155,8 @@ Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
}
expr_ty
-List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!ctx) {
@@ -3156,7 +3164,7 @@ List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
"field 'ctx' is required for List");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = List_kind;
@@ -3170,8 +3178,8 @@ List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
}
expr_ty
-Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
if (!ctx) {
@@ -3179,7 +3187,7 @@ Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
"field 'ctx' is required for Tuple");
return NULL;
}
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Tuple_kind;
@@ -3193,11 +3201,11 @@ Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
}
expr_ty
-Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int col_offset,
- int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
expr_ty p;
- p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = Slice_kind;
@@ -3212,8 +3220,8 @@ Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int col_offset,
}
comprehension_ty
-comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, int is_async,
- PyArena *arena)
+_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
+ is_async, PyArena *arena)
{
comprehension_ty p;
if (!target) {
@@ -3226,7 +3234,7 @@ comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, int is_async,
"field 'iter' is required for comprehension");
return NULL;
}
- p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->target = target;
@@ -3237,11 +3245,12 @@ comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, int is_async,
}
excepthandler_ty
-ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
+ lineno, int col_offset, int end_lineno, int
+ end_col_offset, PyArena *arena)
{
excepthandler_ty p;
- p = (excepthandler_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = ExceptHandler_kind;
@@ -3256,12 +3265,13 @@ ExceptHandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int
}
arguments_ty
-arguments(asdl_seq * posonlyargs, asdl_seq * args, arg_ty vararg, asdl_seq *
- kwonlyargs, asdl_seq * kw_defaults, arg_ty kwarg, asdl_seq *
- defaults, PyArena *arena)
+_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
+ vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
+ kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
+ *arena)
{
arguments_ty p;
- p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->posonlyargs = posonlyargs;
@@ -3275,8 +3285,8 @@ arguments(asdl_seq * posonlyargs, asdl_seq * args, arg_ty vararg, asdl_seq *
}
arg_ty
-arg(identifier arg, expr_ty annotation, string type_comment, int lineno, int
- col_offset, int end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
+ int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
{
arg_ty p;
if (!arg) {
@@ -3284,7 +3294,7 @@ arg(identifier arg, expr_ty annotation, string type_comment, int lineno, int
"field 'arg' is required for arg");
return NULL;
}
- p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->arg = arg;
@@ -3298,8 +3308,8 @@ arg(identifier arg, expr_ty annotation, string type_comment, int lineno, int
}
keyword_ty
-keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
- end_lineno, int end_col_offset, PyArena *arena)
+_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
{
keyword_ty p;
if (!value) {
@@ -3307,7 +3317,7 @@ keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
"field 'value' is required for keyword");
return NULL;
}
- p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->arg = arg;
@@ -3320,7 +3330,8 @@ keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
}
alias_ty
-alias(identifier name, identifier asname, PyArena *arena)
+_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
+ int end_lineno, int end_col_offset, PyArena *arena)
{
alias_ty p;
if (!name) {
@@ -3328,16 +3339,20 @@ alias(identifier name, identifier asname, PyArena *arena)
"field 'name' is required for alias");
return NULL;
}
- p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->name = name;
p->asname = asname;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
return p;
}
withitem_ty
-withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
+_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
{
withitem_ty p;
if (!context_expr) {
@@ -3345,7 +3360,7 @@ withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
"field 'context_expr' is required for withitem");
return NULL;
}
- p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->context_expr = context_expr;
@@ -3353,8 +3368,187 @@ withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
return p;
}
+match_case_ty
+_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
+ PyArena *arena)
+{
+ match_case_ty p;
+ if (!pattern) {
+ PyErr_SetString(PyExc_ValueError,
+ "field 'pattern' is required for match_case");
+ return NULL;
+ }
+ p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->pattern = pattern;
+ p->guard = guard;
+ p->body = body;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
+ int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ if (!value) {
+ PyErr_SetString(PyExc_ValueError,
+ "field 'value' is required for MatchValue");
+ return NULL;
+ }
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchValue_kind;
+ p->v.MatchValue.value = value;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ if (!value) {
+ PyErr_SetString(PyExc_ValueError,
+ "field 'value' is required for MatchSingleton");
+ return NULL;
+ }
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchSingleton_kind;
+ p->v.MatchSingleton.value = value;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
+ int end_lineno, int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchSequence_kind;
+ p->v.MatchSequence.patterns = patterns;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
+ identifier rest, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchMapping_kind;
+ p->v.MatchMapping.keys = keys;
+ p->v.MatchMapping.patterns = patterns;
+ p->v.MatchMapping.rest = rest;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
+ * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
+ col_offset, int end_lineno, int end_col_offset, PyArena
+ *arena)
+{
+ pattern_ty p;
+ if (!cls) {
+ PyErr_SetString(PyExc_ValueError,
+ "field 'cls' is required for MatchClass");
+ return NULL;
+ }
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchClass_kind;
+ p->v.MatchClass.cls = cls;
+ p->v.MatchClass.patterns = patterns;
+ p->v.MatchClass.kwd_attrs = kwd_attrs;
+ p->v.MatchClass.kwd_patterns = kwd_patterns;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
+ int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchStar_kind;
+ p->v.MatchStar.name = name;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
+ int end_lineno, int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchAs_kind;
+ p->v.MatchAs.pattern = pattern;
+ p->v.MatchAs.name = name;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
+pattern_ty
+_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
+ end_lineno, int end_col_offset, PyArena *arena)
+{
+ pattern_ty p;
+ p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
+ if (!p)
+ return NULL;
+ p->kind = MatchOr_kind;
+ p->v.MatchOr.patterns = patterns;
+ p->lineno = lineno;
+ p->col_offset = col_offset;
+ p->end_lineno = end_lineno;
+ p->end_col_offset = end_col_offset;
+ return p;
+}
+
type_ignore_ty
-TypeIgnore(int lineno, string tag, PyArena *arena)
+_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
{
type_ignore_ty p;
if (!tag) {
@@ -3362,7 +3556,7 @@ TypeIgnore(int lineno, string tag, PyArena *arena)
"field 'tag' is required for TypeIgnore");
return NULL;
}
- p = (type_ignore_ty)PyArena_Malloc(arena, sizeof(*p));
+ p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
if (!p)
return NULL;
p->kind = TypeIgnore_kind;
@@ -3373,7 +3567,7 @@ TypeIgnore(int lineno, string tag, PyArena *arena)
PyObject*
-ast2obj_mod(astmodulestate *state, void* _o)
+ast2obj_mod(struct ast_state *state, void* _o)
{
mod_ty o = (mod_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -3386,12 +3580,12 @@ ast2obj_mod(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Module_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Module.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Module.type_ignores,
+ value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
ast2obj_type_ignore);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
@@ -3402,7 +3596,8 @@ ast2obj_mod(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Interactive_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Interactive.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
@@ -3422,7 +3617,8 @@ ast2obj_mod(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->FunctionType_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.FunctionType.argtypes, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->argtypes, value) == -1)
goto failed;
@@ -3442,7 +3638,7 @@ failed:
}
PyObject*
-ast2obj_stmt(astmodulestate *state, void* _o)
+ast2obj_stmt(struct ast_state *state, void* _o)
{
stmt_ty o = (stmt_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -3465,12 +3661,13 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->args, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.FunctionDef.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.FunctionDef.decorator_list,
+ value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
@@ -3501,12 +3698,14 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->args, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.AsyncFunctionDef.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.AsyncFunctionDef.decorator_list,
+ value = ast2obj_list(state,
+ (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
@@ -3532,22 +3731,26 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->name, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ClassDef.bases, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->bases, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ClassDef.keywords, ast2obj_keyword);
+ value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
+ ast2obj_keyword);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->keywords, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ClassDef.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ClassDef.decorator_list, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
goto failed;
@@ -3567,7 +3770,8 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Delete_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Delete.targets, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->targets, value) == -1)
goto failed;
@@ -3577,7 +3781,8 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Assign_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Assign.targets, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->targets, value) == -1)
goto failed;
@@ -3652,12 +3857,12 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->iter, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.For.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.For.orelse, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->orelse, value) == -1)
goto failed;
@@ -3682,12 +3887,14 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->iter, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.AsyncFor.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.AsyncFor.orelse, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->orelse, value) == -1)
goto failed;
@@ -3707,12 +3914,12 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->test, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.While.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.While.orelse, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->orelse, value) == -1)
goto failed;
@@ -3727,12 +3934,12 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->test, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.If.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.If.orelse, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->orelse, value) == -1)
goto failed;
@@ -3742,12 +3949,13 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->With_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.With.items, ast2obj_withitem);
+ value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
+ ast2obj_withitem);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->items, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.With.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
@@ -3762,12 +3970,14 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->AsyncWith_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.AsyncWith.items, ast2obj_withitem);
+ value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
+ ast2obj_withitem);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->items, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.AsyncWith.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
@@ -3778,6 +3988,22 @@ ast2obj_stmt(astmodulestate *state, void* _o)
goto failed;
Py_DECREF(value);
break;
+ case Match_kind:
+ tp = (PyTypeObject *)state->Match_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_expr(state, o->v.Match.subject);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->subject, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
+ ast2obj_match_case);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->cases, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
case Raise_kind:
tp = (PyTypeObject *)state->Raise_type;
result = PyType_GenericNew(tp, NULL, NULL);
@@ -3797,22 +4023,24 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Try_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Try.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Try.handlers, ast2obj_excepthandler);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
+ ast2obj_excepthandler);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->handlers, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Try.orelse, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->orelse, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Try.finalbody, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->finalbody, value) == -1)
goto failed;
@@ -3837,7 +4065,8 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Import_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Import.names, ast2obj_alias);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
+ ast2obj_alias);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->names, value) == -1)
goto failed;
@@ -3852,7 +4081,8 @@ ast2obj_stmt(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->module, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ImportFrom.names, ast2obj_alias);
+ value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
+ ast2obj_alias);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->names, value) == -1)
goto failed;
@@ -3867,7 +4097,8 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Global_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Global.names, ast2obj_identifier);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
+ ast2obj_identifier);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->names, value) == -1)
goto failed;
@@ -3877,7 +4108,8 @@ ast2obj_stmt(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Nonlocal_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Nonlocal.names, ast2obj_identifier);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
+ ast2obj_identifier);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->names, value) == -1)
goto failed;
@@ -3937,7 +4169,7 @@ failed:
}
PyObject*
-ast2obj_expr(astmodulestate *state, void* _o)
+ast2obj_expr(struct ast_state *state, void* _o)
{
expr_ty o = (expr_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -3955,7 +4187,8 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->op, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.BoolOp.values, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->values, value) == -1)
goto failed;
@@ -4050,12 +4283,12 @@ ast2obj_expr(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Dict_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Dict.keys, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->keys, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Dict.values, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->values, value) == -1)
goto failed;
@@ -4065,7 +4298,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Set_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Set.elts, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->elts, value) == -1)
goto failed;
@@ -4080,7 +4313,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->elt, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ListComp.generators,
+ value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
ast2obj_comprehension);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->generators, value) == -1)
@@ -4096,7 +4329,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->elt, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.SetComp.generators,
+ value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
ast2obj_comprehension);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->generators, value) == -1)
@@ -4117,7 +4350,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->value, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.DictComp.generators,
+ value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
ast2obj_comprehension);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->generators, value) == -1)
@@ -4133,7 +4366,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->elt, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.GeneratorExp.generators,
+ value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
ast2obj_comprehension);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->generators, value) == -1)
@@ -4190,7 +4423,8 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->ops, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Compare.comparators, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->comparators, value) == -1)
goto failed;
@@ -4205,12 +4439,13 @@ ast2obj_expr(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->func, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Call.args, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->args, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.Call.keywords, ast2obj_keyword);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
+ ast2obj_keyword);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->keywords, value) == -1)
goto failed;
@@ -4240,7 +4475,8 @@ ast2obj_expr(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->JoinedStr_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.JoinedStr.values, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
+ ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->values, value) == -1)
goto failed;
@@ -4335,7 +4571,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->List_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.List.elts, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->elts, value) == -1)
goto failed;
@@ -4350,7 +4586,7 @@ ast2obj_expr(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->Tuple_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) goto failed;
- value = ast2obj_list(state, o->v.Tuple.elts, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->elts, value) == -1)
goto failed;
@@ -4409,7 +4645,7 @@ failed:
return NULL;
}
-PyObject* ast2obj_expr_context(astmodulestate *state, expr_context_ty o)
+PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
{
switch(o) {
case Load:
@@ -4424,7 +4660,7 @@ PyObject* ast2obj_expr_context(astmodulestate *state, expr_context_ty o)
}
Py_UNREACHABLE();
}
-PyObject* ast2obj_boolop(astmodulestate *state, boolop_ty o)
+PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
{
switch(o) {
case And:
@@ -4436,7 +4672,7 @@ PyObject* ast2obj_boolop(astmodulestate *state, boolop_ty o)
}
Py_UNREACHABLE();
}
-PyObject* ast2obj_operator(astmodulestate *state, operator_ty o)
+PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
{
switch(o) {
case Add:
@@ -4481,7 +4717,7 @@ PyObject* ast2obj_operator(astmodulestate *state, operator_ty o)
}
Py_UNREACHABLE();
}
-PyObject* ast2obj_unaryop(astmodulestate *state, unaryop_ty o)
+PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
{
switch(o) {
case Invert:
@@ -4499,7 +4735,7 @@ PyObject* ast2obj_unaryop(astmodulestate *state, unaryop_ty o)
}
Py_UNREACHABLE();
}
-PyObject* ast2obj_cmpop(astmodulestate *state, cmpop_ty o)
+PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
{
switch(o) {
case Eq:
@@ -4536,7 +4772,7 @@ PyObject* ast2obj_cmpop(astmodulestate *state, cmpop_ty o)
Py_UNREACHABLE();
}
PyObject*
-ast2obj_comprehension(astmodulestate *state, void* _o)
+ast2obj_comprehension(struct ast_state *state, void* _o)
{
comprehension_ty o = (comprehension_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4557,7 +4793,7 @@ ast2obj_comprehension(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->iter, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->ifs, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->ifs, value) == -1)
goto failed;
@@ -4575,7 +4811,7 @@ failed:
}
PyObject*
-ast2obj_excepthandler(astmodulestate *state, void* _o)
+ast2obj_excepthandler(struct ast_state *state, void* _o)
{
excepthandler_ty o = (excepthandler_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4598,7 +4834,8 @@ ast2obj_excepthandler(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->name, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->v.ExceptHandler.body, ast2obj_stmt);
+ value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
+ ast2obj_stmt);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->body, value) == -1)
goto failed;
@@ -4633,7 +4870,7 @@ failed:
}
PyObject*
-ast2obj_arguments(astmodulestate *state, void* _o)
+ast2obj_arguments(struct ast_state *state, void* _o)
{
arguments_ty o = (arguments_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4644,12 +4881,12 @@ ast2obj_arguments(astmodulestate *state, void* _o)
tp = (PyTypeObject *)state->arguments_type;
result = PyType_GenericNew(tp, NULL, NULL);
if (!result) return NULL;
- value = ast2obj_list(state, o->posonlyargs, ast2obj_arg);
+ value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->args, ast2obj_arg);
+ value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->args, value) == -1)
goto failed;
@@ -4659,12 +4896,12 @@ ast2obj_arguments(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->vararg, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->kwonlyargs, ast2obj_arg);
+ value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->kw_defaults, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
goto failed;
@@ -4674,7 +4911,7 @@ ast2obj_arguments(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->kwarg, value) == -1)
goto failed;
Py_DECREF(value);
- value = ast2obj_list(state, o->defaults, ast2obj_expr);
+ value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
if (!value) goto failed;
if (PyObject_SetAttr(result, state->defaults, value) == -1)
goto failed;
@@ -4687,7 +4924,7 @@ failed:
}
PyObject*
-ast2obj_arg(astmodulestate *state, void* _o)
+ast2obj_arg(struct ast_state *state, void* _o)
{
arg_ty o = (arg_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4741,7 +4978,7 @@ failed:
}
PyObject*
-ast2obj_keyword(astmodulestate *state, void* _o)
+ast2obj_keyword(struct ast_state *state, void* _o)
{
keyword_ty o = (keyword_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4790,7 +5027,7 @@ failed:
}
PyObject*
-ast2obj_alias(astmodulestate *state, void* _o)
+ast2obj_alias(struct ast_state *state, void* _o)
{
alias_ty o = (alias_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4811,6 +5048,26 @@ ast2obj_alias(astmodulestate *state, void* _o)
if (PyObject_SetAttr(result, state->asname, value) == -1)
goto failed;
Py_DECREF(value);
+ value = ast2obj_int(state, o->lineno);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->lineno, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(state, o->col_offset);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->col_offset, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(state, o->end_lineno);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(state, o->end_col_offset);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
+ goto failed;
+ Py_DECREF(value);
return result;
failed:
Py_XDECREF(value);
@@ -4819,7 +5076,7 @@ failed:
}
PyObject*
-ast2obj_withitem(astmodulestate *state, void* _o)
+ast2obj_withitem(struct ast_state *state, void* _o)
{
withitem_ty o = (withitem_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4848,7 +5105,196 @@ failed:
}
PyObject*
-ast2obj_type_ignore(astmodulestate *state, void* _o)
+ast2obj_match_case(struct ast_state *state, void* _o)
+{
+ match_case_ty o = (match_case_ty)_o;
+ PyObject *result = NULL, *value = NULL;
+ PyTypeObject *tp;
+ if (!o) {
+ Py_RETURN_NONE;
+ }
+ tp = (PyTypeObject *)state->match_case_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) return NULL;
+ value = ast2obj_pattern(state, o->pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->pattern, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_expr(state, o->guard);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->guard, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->body, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ return result;
+failed:
+ Py_XDECREF(value);
+ Py_XDECREF(result);
+ return NULL;
+}
+
+PyObject*
+ast2obj_pattern(struct ast_state *state, void* _o)
+{
+ pattern_ty o = (pattern_ty)_o;
+ PyObject *result = NULL, *value = NULL;
+ PyTypeObject *tp;
+ if (!o) {
+ Py_RETURN_NONE;
+ }
+ switch (o->kind) {
+ case MatchValue_kind:
+ tp = (PyTypeObject *)state->MatchValue_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_expr(state, o->v.MatchValue.value);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->value, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchSingleton_kind:
+ tp = (PyTypeObject *)state->MatchSingleton_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_constant(state, o->v.MatchSingleton.value);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->value, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchSequence_kind:
+ tp = (PyTypeObject *)state->MatchSequence_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
+ ast2obj_pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->patterns, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchMapping_kind:
+ tp = (PyTypeObject *)state->MatchMapping_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
+ ast2obj_expr);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->keys, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
+ ast2obj_pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->patterns, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_identifier(state, o->v.MatchMapping.rest);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->rest, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchClass_kind:
+ tp = (PyTypeObject *)state->MatchClass_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_expr(state, o->v.MatchClass.cls);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->cls, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
+ ast2obj_pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->patterns, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
+ ast2obj_identifier);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
+ ast2obj_pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchStar_kind:
+ tp = (PyTypeObject *)state->MatchStar_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_identifier(state, o->v.MatchStar.name);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->name, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchAs_kind:
+ tp = (PyTypeObject *)state->MatchAs_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_pattern(state, o->v.MatchAs.pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->pattern, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_identifier(state, o->v.MatchAs.name);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->name, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ case MatchOr_kind:
+ tp = (PyTypeObject *)state->MatchOr_type;
+ result = PyType_GenericNew(tp, NULL, NULL);
+ if (!result) goto failed;
+ value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
+ ast2obj_pattern);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->patterns, value) == -1)
+ goto failed;
+ Py_DECREF(value);
+ break;
+ }
+ value = ast2obj_int(state, o->lineno);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->lineno, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(state, o->col_offset);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->col_offset, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(state, o->end_lineno);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ value = ast2obj_int(state, o->end_col_offset);
+ if (!value) goto failed;
+ if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
+ goto failed;
+ Py_DECREF(value);
+ return result;
+failed:
+ Py_XDECREF(value);
+ Py_XDECREF(result);
+ return NULL;
+}
+
+PyObject*
+ast2obj_type_ignore(struct ast_state *state, void* _o)
{
type_ignore_ty o = (type_ignore_ty)_o;
PyObject *result = NULL, *value = NULL;
@@ -4882,7 +5328,7 @@ failed:
int
-obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
+obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
{
int isinstance;
@@ -4899,8 +5345,8 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* body;
- asdl_seq* type_ignores;
+ asdl_stmt_seq* body;
+ asdl_type_ignore_seq* type_ignores;
if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
return 1;
@@ -4918,7 +5364,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -4955,7 +5401,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- type_ignores = _Py_asdl_seq_new(len, arena);
+ type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
if (type_ignores == NULL) goto failed;
for (i = 0; i < len; i++) {
type_ignore_ty val;
@@ -4976,7 +5422,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Module(body, type_ignores, arena);
+ *out = _PyAST_Module(body, type_ignores, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -4986,7 +5432,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* body;
+ asdl_stmt_seq* body;
if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
return 1;
@@ -5004,7 +5450,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -5025,7 +5471,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Interactive(body, arena);
+ *out = _PyAST_Interactive(body, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5054,7 +5500,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Expression(body, arena);
+ *out = _PyAST_Expression(body, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5064,7 +5510,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* argtypes;
+ asdl_expr_seq* argtypes;
expr_ty returns;
if (_PyObject_LookupAttr(obj, state->argtypes, &tmp) < 0) {
@@ -5083,7 +5529,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- argtypes = _Py_asdl_seq_new(len, arena);
+ argtypes = _Py_asdl_expr_seq_new(len, arena);
if (argtypes == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5121,7 +5567,7 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = FunctionType(argtypes, returns, arena);
+ *out = _PyAST_FunctionType(argtypes, returns, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5133,7 +5579,8 @@ obj2ast_mod(astmodulestate *state, PyObject* obj, mod_ty* out, PyArena* arena)
}
int
-obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
+obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
+ arena)
{
int isinstance;
@@ -5224,8 +5671,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (isinstance) {
identifier name;
arguments_ty args;
- asdl_seq* body;
- asdl_seq* decorator_list;
+ asdl_stmt_seq* body;
+ asdl_expr_seq* decorator_list;
expr_ty returns;
string type_comment;
@@ -5279,7 +5726,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -5316,7 +5763,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- decorator_list = _Py_asdl_seq_new(len, arena);
+ decorator_list = _Py_asdl_expr_seq_new(len, arena);
if (decorator_list == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5371,9 +5818,9 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = FunctionDef(name, args, body, decorator_list, returns,
- type_comment, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
+ type_comment, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5385,8 +5832,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (isinstance) {
identifier name;
arguments_ty args;
- asdl_seq* body;
- asdl_seq* decorator_list;
+ asdl_stmt_seq* body;
+ asdl_expr_seq* decorator_list;
expr_ty returns;
string type_comment;
@@ -5440,7 +5887,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -5477,7 +5924,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- decorator_list = _Py_asdl_seq_new(len, arena);
+ decorator_list = _Py_asdl_expr_seq_new(len, arena);
if (decorator_list == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5532,9 +5979,10 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = AsyncFunctionDef(name, args, body, decorator_list, returns,
- type_comment, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
+ returns, type_comment, lineno,
+ col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5545,10 +5993,10 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
identifier name;
- asdl_seq* bases;
- asdl_seq* keywords;
- asdl_seq* body;
- asdl_seq* decorator_list;
+ asdl_expr_seq* bases;
+ asdl_keyword_seq* keywords;
+ asdl_stmt_seq* body;
+ asdl_expr_seq* decorator_list;
if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
return 1;
@@ -5583,7 +6031,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- bases = _Py_asdl_seq_new(len, arena);
+ bases = _Py_asdl_expr_seq_new(len, arena);
if (bases == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5620,7 +6068,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- keywords = _Py_asdl_seq_new(len, arena);
+ keywords = _Py_asdl_keyword_seq_new(len, arena);
if (keywords == NULL) goto failed;
for (i = 0; i < len; i++) {
keyword_ty val;
@@ -5657,7 +6105,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -5694,7 +6142,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- decorator_list = _Py_asdl_seq_new(len, arena);
+ decorator_list = _Py_asdl_expr_seq_new(len, arena);
if (decorator_list == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5715,8 +6163,9 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = ClassDef(name, bases, keywords, body, decorator_list, lineno,
- col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
+ lineno, col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5745,8 +6194,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Return(value, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5756,7 +6205,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* targets;
+ asdl_expr_seq* targets;
if (_PyObject_LookupAttr(obj, state->targets, &tmp) < 0) {
return 1;
@@ -5774,7 +6223,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- targets = _Py_asdl_seq_new(len, arena);
+ targets = _Py_asdl_expr_seq_new(len, arena);
if (targets == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5795,8 +6244,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Delete(targets, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5806,7 +6255,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* targets;
+ asdl_expr_seq* targets;
expr_ty value;
string type_comment;
@@ -5826,7 +6275,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- targets = _Py_asdl_seq_new(len, arena);
+ targets = _Py_asdl_expr_seq_new(len, arena);
if (targets == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -5881,8 +6330,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Assign(targets, value, type_comment, lineno, col_offset,
- end_lineno, end_col_offset, arena);
+ *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -5947,8 +6396,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = AugAssign(target, op, value, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6031,8 +6480,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = AnnAssign(target, annotation, value, simple, lineno, col_offset,
- end_lineno, end_col_offset, arena);
+ *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
+ col_offset, end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6044,8 +6493,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (isinstance) {
expr_ty target;
expr_ty iter;
- asdl_seq* body;
- asdl_seq* orelse;
+ asdl_stmt_seq* body;
+ asdl_stmt_seq* orelse;
string type_comment;
if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
@@ -6098,7 +6547,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6135,7 +6584,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- orelse = _Py_asdl_seq_new(len, arena);
+ orelse = _Py_asdl_stmt_seq_new(len, arena);
if (orelse == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6173,8 +6622,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = For(target, iter, body, orelse, type_comment, lineno,
- col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
+ col_offset, end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6186,8 +6635,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (isinstance) {
expr_ty target;
expr_ty iter;
- asdl_seq* body;
- asdl_seq* orelse;
+ asdl_stmt_seq* body;
+ asdl_stmt_seq* orelse;
string type_comment;
if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
@@ -6240,7 +6689,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6277,7 +6726,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- orelse = _Py_asdl_seq_new(len, arena);
+ orelse = _Py_asdl_stmt_seq_new(len, arena);
if (orelse == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6315,8 +6764,9 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = AsyncFor(target, iter, body, orelse, type_comment, lineno,
- col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
+ lineno, col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6327,8 +6777,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
expr_ty test;
- asdl_seq* body;
- asdl_seq* orelse;
+ asdl_stmt_seq* body;
+ asdl_stmt_seq* orelse;
if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
return 1;
@@ -6363,7 +6813,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6400,7 +6850,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- orelse = _Py_asdl_seq_new(len, arena);
+ orelse = _Py_asdl_stmt_seq_new(len, arena);
if (orelse == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6421,8 +6871,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = While(test, body, orelse, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6433,8 +6883,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
expr_ty test;
- asdl_seq* body;
- asdl_seq* orelse;
+ asdl_stmt_seq* body;
+ asdl_stmt_seq* orelse;
if (_PyObject_LookupAttr(obj, state->test, &tmp) < 0) {
return 1;
@@ -6469,7 +6919,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6506,7 +6956,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- orelse = _Py_asdl_seq_new(len, arena);
+ orelse = _Py_asdl_stmt_seq_new(len, arena);
if (orelse == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6527,8 +6977,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = If(test, body, orelse, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6538,8 +6988,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* items;
- asdl_seq* body;
+ asdl_withitem_seq* items;
+ asdl_stmt_seq* body;
string type_comment;
if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
@@ -6558,7 +7008,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- items = _Py_asdl_seq_new(len, arena);
+ items = _Py_asdl_withitem_seq_new(len, arena);
if (items == NULL) goto failed;
for (i = 0; i < len; i++) {
withitem_ty val;
@@ -6595,7 +7045,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6633,8 +7083,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = With(items, body, type_comment, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6644,8 +7094,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* items;
- asdl_seq* body;
+ asdl_withitem_seq* items;
+ asdl_stmt_seq* body;
string type_comment;
if (_PyObject_LookupAttr(obj, state->items, &tmp) < 0) {
@@ -6664,7 +7114,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- items = _Py_asdl_seq_new(len, arena);
+ items = _Py_asdl_withitem_seq_new(len, arena);
if (items == NULL) goto failed;
for (i = 0; i < len; i++) {
withitem_ty val;
@@ -6701,7 +7151,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6739,8 +7189,76 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = AsyncWith(items, body, type_comment, lineno, col_offset,
- end_lineno, end_col_offset, arena);
+ *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->Match_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ expr_ty subject;
+ asdl_match_case_seq* cases;
+
+ if (_PyObject_LookupAttr(obj, state->subject, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'Match' node")) {
+ goto failed;
+ }
+ res = obj2ast_expr(state, tmp, &subject, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->cases, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"cases\" missing from Match");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ cases = _Py_asdl_match_case_seq_new(len, arena);
+ if (cases == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ match_case_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'Match' node")) {
+ goto failed;
+ }
+ res = obj2ast_match_case(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(cases, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6787,8 +7305,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Raise(exc, cause, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6798,10 +7316,10 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* body;
- asdl_seq* handlers;
- asdl_seq* orelse;
- asdl_seq* finalbody;
+ asdl_stmt_seq* body;
+ asdl_excepthandler_seq* handlers;
+ asdl_stmt_seq* orelse;
+ asdl_stmt_seq* finalbody;
if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
return 1;
@@ -6819,7 +7337,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6856,7 +7374,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- handlers = _Py_asdl_seq_new(len, arena);
+ handlers = _Py_asdl_excepthandler_seq_new(len, arena);
if (handlers == NULL) goto failed;
for (i = 0; i < len; i++) {
excepthandler_ty val;
@@ -6893,7 +7411,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- orelse = _Py_asdl_seq_new(len, arena);
+ orelse = _Py_asdl_stmt_seq_new(len, arena);
if (orelse == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6930,7 +7448,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- finalbody = _Py_asdl_seq_new(len, arena);
+ finalbody = _Py_asdl_stmt_seq_new(len, arena);
if (finalbody == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -6951,8 +7469,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Try(body, handlers, orelse, finalbody, lineno, col_offset,
- end_lineno, end_col_offset, arena);
+ *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
+ col_offset, end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -6999,8 +7517,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Assert(test, msg, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7010,7 +7528,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* names;
+ asdl_alias_seq* names;
if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
return 1;
@@ -7028,7 +7546,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- names = _Py_asdl_seq_new(len, arena);
+ names = _Py_asdl_alias_seq_new(len, arena);
if (names == NULL) goto failed;
for (i = 0; i < len; i++) {
alias_ty val;
@@ -7049,8 +7567,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Import(names, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7061,7 +7579,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
identifier module;
- asdl_seq* names;
+ asdl_alias_seq* names;
int level;
if (_PyObject_LookupAttr(obj, state->module, &tmp) < 0) {
@@ -7097,7 +7615,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- names = _Py_asdl_seq_new(len, arena);
+ names = _Py_asdl_alias_seq_new(len, arena);
if (names == NULL) goto failed;
for (i = 0; i < len; i++) {
alias_ty val;
@@ -7135,8 +7653,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = ImportFrom(module, names, level, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7146,7 +7664,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* names;
+ asdl_identifier_seq* names;
if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
return 1;
@@ -7164,7 +7682,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- names = _Py_asdl_seq_new(len, arena);
+ names = _Py_asdl_identifier_seq_new(len, arena);
if (names == NULL) goto failed;
for (i = 0; i < len; i++) {
identifier val;
@@ -7185,8 +7703,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Global(names, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7196,7 +7714,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* names;
+ asdl_identifier_seq* names;
if (_PyObject_LookupAttr(obj, state->names, &tmp) < 0) {
return 1;
@@ -7214,7 +7732,7 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- names = _Py_asdl_seq_new(len, arena);
+ names = _Py_asdl_identifier_seq_new(len, arena);
if (names == NULL) goto failed;
for (i = 0; i < len; i++) {
identifier val;
@@ -7235,8 +7753,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Nonlocal(names, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7265,8 +7783,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Expr(value, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7277,7 +7795,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
- *out = Pass(lineno, col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7288,7 +7807,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
- *out = Break(lineno, col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7299,7 +7819,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
if (isinstance) {
- *out = Continue(lineno, col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7311,7 +7832,8 @@ obj2ast_stmt(astmodulestate *state, PyObject* obj, stmt_ty* out, PyArena* arena)
}
int
-obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
+obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
+ arena)
{
int isinstance;
@@ -7401,7 +7923,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
if (isinstance) {
boolop_ty op;
- asdl_seq* values;
+ asdl_expr_seq* values;
if (_PyObject_LookupAttr(obj, state->op, &tmp) < 0) {
return 1;
@@ -7436,7 +7958,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- values = _Py_asdl_seq_new(len, arena);
+ values = _Py_asdl_expr_seq_new(len, arena);
if (values == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -7457,8 +7979,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = BoolOp(op, values, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7505,8 +8027,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = NamedExpr(target, value, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7571,8 +8093,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = BinOp(left, op, right, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7619,8 +8141,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = UnaryOp(op, operand, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7667,8 +8189,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Lambda(args, body, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7733,8 +8255,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = IfExp(test, body, orelse, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7744,8 +8266,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* keys;
- asdl_seq* values;
+ asdl_expr_seq* keys;
+ asdl_expr_seq* values;
if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
return 1;
@@ -7763,7 +8285,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- keys = _Py_asdl_seq_new(len, arena);
+ keys = _Py_asdl_expr_seq_new(len, arena);
if (keys == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -7800,7 +8322,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- values = _Py_asdl_seq_new(len, arena);
+ values = _Py_asdl_expr_seq_new(len, arena);
if (values == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -7821,8 +8343,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Dict(keys, values, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7832,7 +8354,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* elts;
+ asdl_expr_seq* elts;
if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
return 1;
@@ -7850,7 +8372,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- elts = _Py_asdl_seq_new(len, arena);
+ elts = _Py_asdl_expr_seq_new(len, arena);
if (elts == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -7871,7 +8393,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Set(elts, lineno, col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7882,7 +8405,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
if (isinstance) {
expr_ty elt;
- asdl_seq* generators;
+ asdl_comprehension_seq* generators;
if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
return 1;
@@ -7917,7 +8440,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- generators = _Py_asdl_seq_new(len, arena);
+ generators = _Py_asdl_comprehension_seq_new(len, arena);
if (generators == NULL) goto failed;
for (i = 0; i < len; i++) {
comprehension_ty val;
@@ -7938,8 +8461,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = ListComp(elt, generators, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -7950,7 +8473,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
if (isinstance) {
expr_ty elt;
- asdl_seq* generators;
+ asdl_comprehension_seq* generators;
if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
return 1;
@@ -7985,7 +8508,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- generators = _Py_asdl_seq_new(len, arena);
+ generators = _Py_asdl_comprehension_seq_new(len, arena);
if (generators == NULL) goto failed;
for (i = 0; i < len; i++) {
comprehension_ty val;
@@ -8006,8 +8529,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = SetComp(elt, generators, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8019,7 +8542,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (isinstance) {
expr_ty key;
expr_ty value;
- asdl_seq* generators;
+ asdl_comprehension_seq* generators;
if (_PyObject_LookupAttr(obj, state->key, &tmp) < 0) {
return 1;
@@ -8071,7 +8594,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- generators = _Py_asdl_seq_new(len, arena);
+ generators = _Py_asdl_comprehension_seq_new(len, arena);
if (generators == NULL) goto failed;
for (i = 0; i < len; i++) {
comprehension_ty val;
@@ -8092,8 +8615,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = DictComp(key, value, generators, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8104,7 +8627,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
if (isinstance) {
expr_ty elt;
- asdl_seq* generators;
+ asdl_comprehension_seq* generators;
if (_PyObject_LookupAttr(obj, state->elt, &tmp) < 0) {
return 1;
@@ -8139,7 +8662,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- generators = _Py_asdl_seq_new(len, arena);
+ generators = _Py_asdl_comprehension_seq_new(len, arena);
if (generators == NULL) goto failed;
for (i = 0; i < len; i++) {
comprehension_ty val;
@@ -8160,8 +8683,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = GeneratorExp(elt, generators, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8190,8 +8713,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Await(value, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8220,8 +8743,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Yield(value, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8250,8 +8773,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = YieldFrom(value, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8263,7 +8786,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (isinstance) {
expr_ty left;
asdl_int_seq* ops;
- asdl_seq* comparators;
+ asdl_expr_seq* comparators;
if (_PyObject_LookupAttr(obj, state->left, &tmp) < 0) {
return 1;
@@ -8335,7 +8858,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- comparators = _Py_asdl_seq_new(len, arena);
+ comparators = _Py_asdl_expr_seq_new(len, arena);
if (comparators == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -8356,8 +8879,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Compare(left, ops, comparators, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8368,8 +8891,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
if (isinstance) {
expr_ty func;
- asdl_seq* args;
- asdl_seq* keywords;
+ asdl_expr_seq* args;
+ asdl_keyword_seq* keywords;
if (_PyObject_LookupAttr(obj, state->func, &tmp) < 0) {
return 1;
@@ -8404,7 +8927,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- args = _Py_asdl_seq_new(len, arena);
+ args = _Py_asdl_expr_seq_new(len, arena);
if (args == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -8441,7 +8964,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- keywords = _Py_asdl_seq_new(len, arena);
+ keywords = _Py_asdl_keyword_seq_new(len, arena);
if (keywords == NULL) goto failed;
for (i = 0; i < len; i++) {
keyword_ty val;
@@ -8462,8 +8985,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = Call(func, args, keywords, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8497,9 +9020,9 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (_PyObject_LookupAttr(obj, state->conversion, &tmp) < 0) {
return 1;
}
- if (tmp == NULL || tmp == Py_None) {
- Py_CLEAR(tmp);
- conversion = 0;
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
+ return 1;
}
else {
int res;
@@ -8528,8 +9051,9 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = FormattedValue(value, conversion, format_spec, lineno,
- col_offset, end_lineno, end_col_offset, arena);
+ *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
+ col_offset, end_lineno, end_col_offset,
+ arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8539,7 +9063,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* values;
+ asdl_expr_seq* values;
if (_PyObject_LookupAttr(obj, state->values, &tmp) < 0) {
return 1;
@@ -8557,7 +9081,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- values = _Py_asdl_seq_new(len, arena);
+ values = _Py_asdl_expr_seq_new(len, arena);
if (values == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -8578,8 +9102,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
Py_CLEAR(tmp);
}
- *out = JoinedStr(values, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8626,8 +9150,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Constant(value, kind, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8692,8 +9216,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Attribute(value, attr, ctx, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8758,8 +9282,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Subscript(value, slice, ctx, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8806,8 +9330,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Starred(value, ctx, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8854,8 +9378,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Name(id, ctx, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8865,7 +9389,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* elts;
+ asdl_expr_seq* elts;
expr_context_ty ctx;
if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
@@ -8884,7 +9408,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- elts = _Py_asdl_seq_new(len, arena);
+ elts = _Py_asdl_expr_seq_new(len, arena);
if (elts == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -8922,8 +9446,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = List(elts, ctx, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -8933,7 +9457,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
return 1;
}
if (isinstance) {
- asdl_seq* elts;
+ asdl_expr_seq* elts;
expr_context_ty ctx;
if (_PyObject_LookupAttr(obj, state->elts, &tmp) < 0) {
@@ -8952,7 +9476,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
goto failed;
}
len = PyList_GET_SIZE(tmp);
- elts = _Py_asdl_seq_new(len, arena);
+ elts = _Py_asdl_expr_seq_new(len, arena);
if (elts == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -8990,8 +9514,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Tuple(elts, ctx, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -9056,8 +9580,8 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = Slice(lower, upper, step, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -9069,7 +9593,7 @@ obj2ast_expr(astmodulestate *state, PyObject* obj, expr_ty* out, PyArena* arena)
}
int
-obj2ast_expr_context(astmodulestate *state, PyObject* obj, expr_context_ty*
+obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
out, PyArena* arena)
{
int isinstance;
@@ -9104,7 +9628,7 @@ obj2ast_expr_context(astmodulestate *state, PyObject* obj, expr_context_ty*
}
int
-obj2ast_boolop(astmodulestate *state, PyObject* obj, boolop_ty* out, PyArena*
+obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
arena)
{
int isinstance;
@@ -9131,7 +9655,7 @@ obj2ast_boolop(astmodulestate *state, PyObject* obj, boolop_ty* out, PyArena*
}
int
-obj2ast_operator(astmodulestate *state, PyObject* obj, operator_ty* out,
+obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
PyArena* arena)
{
int isinstance;
@@ -9246,8 +9770,8 @@ obj2ast_operator(astmodulestate *state, PyObject* obj, operator_ty* out,
}
int
-obj2ast_unaryop(astmodulestate *state, PyObject* obj, unaryop_ty* out, PyArena*
- arena)
+obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
+ PyArena* arena)
{
int isinstance;
@@ -9289,7 +9813,7 @@ obj2ast_unaryop(astmodulestate *state, PyObject* obj, unaryop_ty* out, PyArena*
}
int
-obj2ast_cmpop(astmodulestate *state, PyObject* obj, cmpop_ty* out, PyArena*
+obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
arena)
{
int isinstance;
@@ -9380,13 +9904,13 @@ obj2ast_cmpop(astmodulestate *state, PyObject* obj, cmpop_ty* out, PyArena*
}
int
-obj2ast_comprehension(astmodulestate *state, PyObject* obj, comprehension_ty*
+obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
out, PyArena* arena)
{
PyObject* tmp = NULL;
expr_ty target;
expr_ty iter;
- asdl_seq* ifs;
+ asdl_expr_seq* ifs;
int is_async;
if (_PyObject_LookupAttr(obj, state->target, &tmp) < 0) {
@@ -9439,7 +9963,7 @@ obj2ast_comprehension(astmodulestate *state, PyObject* obj, comprehension_ty*
goto failed;
}
len = PyList_GET_SIZE(tmp);
- ifs = _Py_asdl_seq_new(len, arena);
+ ifs = _Py_asdl_expr_seq_new(len, arena);
if (ifs == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -9477,7 +10001,7 @@ obj2ast_comprehension(astmodulestate *state, PyObject* obj, comprehension_ty*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = comprehension(target, iter, ifs, is_async, arena);
+ *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
return 0;
failed:
Py_XDECREF(tmp);
@@ -9485,7 +10009,7 @@ failed:
}
int
-obj2ast_excepthandler(astmodulestate *state, PyObject* obj, excepthandler_ty*
+obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
out, PyArena* arena)
{
int isinstance;
@@ -9577,7 +10101,7 @@ obj2ast_excepthandler(astmodulestate *state, PyObject* obj, excepthandler_ty*
if (isinstance) {
expr_ty type;
identifier name;
- asdl_seq* body;
+ asdl_stmt_seq* body;
if (_PyObject_LookupAttr(obj, state->type, &tmp) < 0) {
return 1;
@@ -9629,7 +10153,7 @@ obj2ast_excepthandler(astmodulestate *state, PyObject* obj, excepthandler_ty*
goto failed;
}
len = PyList_GET_SIZE(tmp);
- body = _Py_asdl_seq_new(len, arena);
+ body = _Py_asdl_stmt_seq_new(len, arena);
if (body == NULL) goto failed;
for (i = 0; i < len; i++) {
stmt_ty val;
@@ -9650,8 +10174,8 @@ obj2ast_excepthandler(astmodulestate *state, PyObject* obj, excepthandler_ty*
}
Py_CLEAR(tmp);
}
- *out = ExceptHandler(type, name, body, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -9663,17 +10187,17 @@ obj2ast_excepthandler(astmodulestate *state, PyObject* obj, excepthandler_ty*
}
int
-obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
+obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
PyArena* arena)
{
PyObject* tmp = NULL;
- asdl_seq* posonlyargs;
- asdl_seq* args;
+ asdl_arg_seq* posonlyargs;
+ asdl_arg_seq* args;
arg_ty vararg;
- asdl_seq* kwonlyargs;
- asdl_seq* kw_defaults;
+ asdl_arg_seq* kwonlyargs;
+ asdl_expr_seq* kw_defaults;
arg_ty kwarg;
- asdl_seq* defaults;
+ asdl_expr_seq* defaults;
if (_PyObject_LookupAttr(obj, state->posonlyargs, &tmp) < 0) {
return 1;
@@ -9691,7 +10215,7 @@ obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
goto failed;
}
len = PyList_GET_SIZE(tmp);
- posonlyargs = _Py_asdl_seq_new(len, arena);
+ posonlyargs = _Py_asdl_arg_seq_new(len, arena);
if (posonlyargs == NULL) goto failed;
for (i = 0; i < len; i++) {
arg_ty val;
@@ -9728,7 +10252,7 @@ obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
goto failed;
}
len = PyList_GET_SIZE(tmp);
- args = _Py_asdl_seq_new(len, arena);
+ args = _Py_asdl_arg_seq_new(len, arena);
if (args == NULL) goto failed;
for (i = 0; i < len; i++) {
arg_ty val;
@@ -9782,7 +10306,7 @@ obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
goto failed;
}
len = PyList_GET_SIZE(tmp);
- kwonlyargs = _Py_asdl_seq_new(len, arena);
+ kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
if (kwonlyargs == NULL) goto failed;
for (i = 0; i < len; i++) {
arg_ty val;
@@ -9819,7 +10343,7 @@ obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
goto failed;
}
len = PyList_GET_SIZE(tmp);
- kw_defaults = _Py_asdl_seq_new(len, arena);
+ kw_defaults = _Py_asdl_expr_seq_new(len, arena);
if (kw_defaults == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -9873,7 +10397,7 @@ obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
goto failed;
}
len = PyList_GET_SIZE(tmp);
- defaults = _Py_asdl_seq_new(len, arena);
+ defaults = _Py_asdl_expr_seq_new(len, arena);
if (defaults == NULL) goto failed;
for (i = 0; i < len; i++) {
expr_ty val;
@@ -9894,8 +10418,8 @@ obj2ast_arguments(astmodulestate *state, PyObject* obj, arguments_ty* out,
}
Py_CLEAR(tmp);
}
- *out = arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults, kwarg,
- defaults, arena);
+ *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
+ kwarg, defaults, arena);
return 0;
failed:
Py_XDECREF(tmp);
@@ -9903,7 +10427,7 @@ failed:
}
int
-obj2ast_arg(astmodulestate *state, PyObject* obj, arg_ty* out, PyArena* arena)
+obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
identifier arg;
@@ -10033,8 +10557,8 @@ obj2ast_arg(astmodulestate *state, PyObject* obj, arg_ty* out, PyArena* arena)
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = arg(arg, annotation, type_comment, lineno, col_offset, end_lineno,
- end_col_offset, arena);
+ *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
return 0;
failed:
Py_XDECREF(tmp);
@@ -10042,8 +10566,8 @@ failed:
}
int
-obj2ast_keyword(astmodulestate *state, PyObject* obj, keyword_ty* out, PyArena*
- arena)
+obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
+ PyArena* arena)
{
PyObject* tmp = NULL;
identifier arg;
@@ -10155,8 +10679,8 @@ obj2ast_keyword(astmodulestate *state, PyObject* obj, keyword_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = keyword(arg, value, lineno, col_offset, end_lineno, end_col_offset,
- arena);
+ *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
return 0;
failed:
Py_XDECREF(tmp);
@@ -10164,12 +10688,16 @@ failed:
}
int
-obj2ast_alias(astmodulestate *state, PyObject* obj, alias_ty* out, PyArena*
+obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
arena)
{
PyObject* tmp = NULL;
identifier name;
identifier asname;
+ int lineno;
+ int col_offset;
+ int end_lineno;
+ int end_col_offset;
if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
return 1;
@@ -10205,7 +10733,76 @@ obj2ast_alias(astmodulestate *state, PyObject* obj, alias_ty* out, PyArena*
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = alias(name, asname, arena);
+ if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'alias' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &lineno, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'alias' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &col_offset, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ end_lineno = 0;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'alias' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &end_lineno, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ end_col_offset = 0;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'alias' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &end_col_offset, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
return 0;
failed:
Py_XDECREF(tmp);
@@ -10213,7 +10810,7 @@ failed:
}
int
-obj2ast_withitem(astmodulestate *state, PyObject* obj, withitem_ty* out,
+obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
PyArena* arena)
{
PyObject* tmp = NULL;
@@ -10254,7 +10851,94 @@ obj2ast_withitem(astmodulestate *state, PyObject* obj, withitem_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = withitem(context_expr, optional_vars, arena);
+ *out = _PyAST_withitem(context_expr, optional_vars, arena);
+ return 0;
+failed:
+ Py_XDECREF(tmp);
+ return 1;
+}
+
+int
+obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
+ PyArena* arena)
+{
+ PyObject* tmp = NULL;
+ pattern_ty pattern;
+ expr_ty guard;
+ asdl_stmt_seq* body;
+
+ if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp, &pattern, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->guard, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ guard = NULL;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
+ goto failed;
+ }
+ res = obj2ast_expr(state, tmp, &guard, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->body, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from match_case");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ body = _Py_asdl_stmt_seq_new(len, arena);
+ if (body == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ stmt_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
+ goto failed;
+ }
+ res = obj2ast_stmt(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(body, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_match_case(pattern, guard, body, arena);
return 0;
failed:
Py_XDECREF(tmp);
@@ -10262,8 +10946,589 @@ failed:
}
int
-obj2ast_type_ignore(astmodulestate *state, PyObject* obj, type_ignore_ty* out,
- PyArena* arena)
+obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
+ PyArena* arena)
+{
+ int isinstance;
+
+ PyObject *tmp = NULL;
+ PyObject *tp;
+ int lineno;
+ int col_offset;
+ int end_lineno;
+ int end_col_offset;
+
+ if (obj == Py_None) {
+ *out = NULL;
+ return 0;
+ }
+ if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &lineno, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &col_offset, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &end_lineno, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
+ goto failed;
+ }
+ res = obj2ast_int(state, tmp, &end_col_offset, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ tp = state->MatchValue_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ expr_ty value;
+
+ if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
+ goto failed;
+ }
+ res = obj2ast_expr(state, tmp, &value, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchSingleton_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ constant value;
+
+ if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
+ goto failed;
+ }
+ res = obj2ast_constant(state, tmp, &value, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchSequence_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ asdl_pattern_seq* patterns;
+
+ if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchSequence");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ patterns = _Py_asdl_pattern_seq_new(len, arena);
+ if (patterns == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ pattern_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(patterns, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchMapping_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ asdl_expr_seq* keys;
+ asdl_pattern_seq* patterns;
+ identifier rest;
+
+ if (_PyObject_LookupAttr(obj, state->keys, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from MatchMapping");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ keys = _Py_asdl_expr_seq_new(len, arena);
+ if (keys == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ expr_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
+ goto failed;
+ }
+ res = obj2ast_expr(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(keys, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchMapping");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ patterns = _Py_asdl_pattern_seq_new(len, arena);
+ if (patterns == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ pattern_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(patterns, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->rest, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ rest = NULL;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
+ goto failed;
+ }
+ res = obj2ast_identifier(state, tmp, &rest, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
+ end_lineno, end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchClass_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ expr_ty cls;
+ asdl_pattern_seq* patterns;
+ asdl_identifier_seq* kwd_attrs;
+ asdl_pattern_seq* kwd_patterns;
+
+ if (_PyObject_LookupAttr(obj, state->cls, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
+ return 1;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
+ goto failed;
+ }
+ res = obj2ast_expr(state, tmp, &cls, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchClass");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ patterns = _Py_asdl_pattern_seq_new(len, arena);
+ if (patterns == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ pattern_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(patterns, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->kwd_attrs, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"kwd_attrs\" missing from MatchClass");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
+ if (kwd_attrs == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ identifier val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
+ goto failed;
+ }
+ res = obj2ast_identifier(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(kwd_attrs, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->kwd_patterns, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"kwd_patterns\" missing from MatchClass");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
+ if (kwd_patterns == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ pattern_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(kwd_patterns, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
+ lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchStar_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ identifier name;
+
+ if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ name = NULL;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
+ goto failed;
+ }
+ res = obj2ast_identifier(state, tmp, &name, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchAs_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ pattern_ty pattern;
+ identifier name;
+
+ if (_PyObject_LookupAttr(obj, state->pattern, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ pattern = NULL;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp, &pattern, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL || tmp == Py_None) {
+ Py_CLEAR(tmp);
+ name = NULL;
+ }
+ else {
+ int res;
+ if (Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
+ goto failed;
+ }
+ res = obj2ast_identifier(state, tmp, &name, arena);
+ Py_LeaveRecursiveCall();
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ tp = state->MatchOr_type;
+ isinstance = PyObject_IsInstance(obj, tp);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ asdl_pattern_seq* patterns;
+
+ if (_PyObject_LookupAttr(obj, state->patterns, &tmp) < 0) {
+ return 1;
+ }
+ if (tmp == NULL) {
+ PyErr_SetString(PyExc_TypeError, "required field \"patterns\" missing from MatchOr");
+ return 1;
+ }
+ else {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
+ goto failed;
+ }
+ len = PyList_GET_SIZE(tmp);
+ patterns = _Py_asdl_pattern_seq_new(len, arena);
+ if (patterns == NULL) goto failed;
+ for (i = 0; i < len; i++) {
+ pattern_ty val;
+ PyObject *tmp2 = PyList_GET_ITEM(tmp, i);
+ Py_INCREF(tmp2);
+ if (Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
+ goto failed;
+ }
+ res = obj2ast_pattern(state, tmp2, &val, arena);
+ Py_LeaveRecursiveCall();
+ Py_DECREF(tmp2);
+ if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
+ goto failed;
+ }
+ asdl_seq_SET(patterns, i, val);
+ }
+ Py_CLEAR(tmp);
+ }
+ *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
+ end_col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+
+ PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
+ failed:
+ Py_XDECREF(tmp);
+ return 1;
+}
+
+int
+obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
+ out, PyArena* arena)
{
int isinstance;
@@ -10317,7 +11582,7 @@ obj2ast_type_ignore(astmodulestate *state, PyObject* obj, type_ignore_ty* out,
if (res != 0) goto failed;
Py_CLEAR(tmp);
}
- *out = TypeIgnore(lineno, tag, arena);
+ *out = _PyAST_TypeIgnore(lineno, tag, arena);
if (*out == NULL) goto failed;
return 0;
}
@@ -10332,15 +11597,13 @@ obj2ast_type_ignore(astmodulestate *state, PyObject* obj, type_ignore_ty* out,
static int
astmodule_exec(PyObject *m)
{
- astmodulestate *state = get_ast_state(m);
-
- if (!init_types(state)) {
+ struct ast_state *state = get_ast_state();
+ if (state == NULL) {
return -1;
}
- if (PyModule_AddObject(m, "AST", state->AST_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
return -1;
}
- Py_INCREF(state->AST_type);
if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
return -1;
}
@@ -10350,432 +11613,368 @@ astmodule_exec(PyObject *m)
if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
return -1;
}
- if (PyModule_AddObject(m, "mod", state->mod_type) < 0) {
+ if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
return -1;
}
- Py_INCREF(state->mod_type);
- if (PyModule_AddObject(m, "Module", state->Module_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
return -1;
}
- Py_INCREF(state->Module_type);
- if (PyModule_AddObject(m, "Interactive", state->Interactive_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
return -1;
}
- Py_INCREF(state->Interactive_type);
- if (PyModule_AddObject(m, "Expression", state->Expression_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
return -1;
}
- Py_INCREF(state->Expression_type);
- if (PyModule_AddObject(m, "FunctionType", state->FunctionType_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
+ {
return -1;
}
- Py_INCREF(state->FunctionType_type);
- if (PyModule_AddObject(m, "stmt", state->stmt_type) < 0) {
+ if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
return -1;
}
- Py_INCREF(state->stmt_type);
- if (PyModule_AddObject(m, "FunctionDef", state->FunctionDef_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
return -1;
}
- Py_INCREF(state->FunctionDef_type);
- if (PyModule_AddObject(m, "AsyncFunctionDef", state->AsyncFunctionDef_type)
- < 0) {
+ if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
+ state->AsyncFunctionDef_type) < 0) {
return -1;
}
- Py_INCREF(state->AsyncFunctionDef_type);
- if (PyModule_AddObject(m, "ClassDef", state->ClassDef_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
return -1;
}
- Py_INCREF(state->ClassDef_type);
- if (PyModule_AddObject(m, "Return", state->Return_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
return -1;
}
- Py_INCREF(state->Return_type);
- if (PyModule_AddObject(m, "Delete", state->Delete_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
return -1;
}
- Py_INCREF(state->Delete_type);
- if (PyModule_AddObject(m, "Assign", state->Assign_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
return -1;
}
- Py_INCREF(state->Assign_type);
- if (PyModule_AddObject(m, "AugAssign", state->AugAssign_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
return -1;
}
- Py_INCREF(state->AugAssign_type);
- if (PyModule_AddObject(m, "AnnAssign", state->AnnAssign_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
return -1;
}
- Py_INCREF(state->AnnAssign_type);
- if (PyModule_AddObject(m, "For", state->For_type) < 0) {
+ if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
return -1;
}
- Py_INCREF(state->For_type);
- if (PyModule_AddObject(m, "AsyncFor", state->AsyncFor_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
return -1;
}
- Py_INCREF(state->AsyncFor_type);
- if (PyModule_AddObject(m, "While", state->While_type) < 0) {
+ if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
return -1;
}
- Py_INCREF(state->While_type);
- if (PyModule_AddObject(m, "If", state->If_type) < 0) {
+ if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
return -1;
}
- Py_INCREF(state->If_type);
- if (PyModule_AddObject(m, "With", state->With_type) < 0) {
+ if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
return -1;
}
- Py_INCREF(state->With_type);
- if (PyModule_AddObject(m, "AsyncWith", state->AsyncWith_type) < 0) {
+ if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
return -1;
}
- Py_INCREF(state->AsyncWith_type);
- if (PyModule_AddObject(m, "Raise", state->Raise_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
return -1;
}
- Py_INCREF(state->Raise_type);
- if (PyModule_AddObject(m, "Try", state->Try_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
return -1;
}
- Py_INCREF(state->Try_type);
- if (PyModule_AddObject(m, "Assert", state->Assert_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
return -1;
}
- Py_INCREF(state->Assert_type);
- if (PyModule_AddObject(m, "Import", state->Import_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
return -1;
}
- Py_INCREF(state->Import_type);
- if (PyModule_AddObject(m, "ImportFrom", state->ImportFrom_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
return -1;
}
- Py_INCREF(state->ImportFrom_type);
- if (PyModule_AddObject(m, "Global", state->Global_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
return -1;
}
- Py_INCREF(state->Global_type);
- if (PyModule_AddObject(m, "Nonlocal", state->Nonlocal_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
return -1;
}
- Py_INCREF(state->Nonlocal_type);
- if (PyModule_AddObject(m, "Expr", state->Expr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
return -1;
}
- Py_INCREF(state->Expr_type);
- if (PyModule_AddObject(m, "Pass", state->Pass_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
return -1;
}
- Py_INCREF(state->Pass_type);
- if (PyModule_AddObject(m, "Break", state->Break_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
return -1;
}
- Py_INCREF(state->Break_type);
- if (PyModule_AddObject(m, "Continue", state->Continue_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
return -1;
}
- Py_INCREF(state->Continue_type);
- if (PyModule_AddObject(m, "expr", state->expr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
return -1;
}
- Py_INCREF(state->expr_type);
- if (PyModule_AddObject(m, "BoolOp", state->BoolOp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
return -1;
}
- Py_INCREF(state->BoolOp_type);
- if (PyModule_AddObject(m, "NamedExpr", state->NamedExpr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
return -1;
}
- Py_INCREF(state->NamedExpr_type);
- if (PyModule_AddObject(m, "BinOp", state->BinOp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
return -1;
}
- Py_INCREF(state->BinOp_type);
- if (PyModule_AddObject(m, "UnaryOp", state->UnaryOp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
return -1;
}
- Py_INCREF(state->UnaryOp_type);
- if (PyModule_AddObject(m, "Lambda", state->Lambda_type) < 0) {
+ if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
return -1;
}
- Py_INCREF(state->Lambda_type);
- if (PyModule_AddObject(m, "IfExp", state->IfExp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
return -1;
}
- Py_INCREF(state->IfExp_type);
- if (PyModule_AddObject(m, "Dict", state->Dict_type) < 0) {
+ if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
return -1;
}
- Py_INCREF(state->Dict_type);
- if (PyModule_AddObject(m, "Set", state->Set_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
return -1;
}
- Py_INCREF(state->Set_type);
- if (PyModule_AddObject(m, "ListComp", state->ListComp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
return -1;
}
- Py_INCREF(state->ListComp_type);
- if (PyModule_AddObject(m, "SetComp", state->SetComp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
return -1;
}
- Py_INCREF(state->SetComp_type);
- if (PyModule_AddObject(m, "DictComp", state->DictComp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
return -1;
}
- Py_INCREF(state->DictComp_type);
- if (PyModule_AddObject(m, "GeneratorExp", state->GeneratorExp_type) < 0) {
+ if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
return -1;
}
- Py_INCREF(state->GeneratorExp_type);
- if (PyModule_AddObject(m, "Await", state->Await_type) < 0) {
+ if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
+ {
return -1;
}
- Py_INCREF(state->Await_type);
- if (PyModule_AddObject(m, "Yield", state->Yield_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
return -1;
}
- Py_INCREF(state->Yield_type);
- if (PyModule_AddObject(m, "YieldFrom", state->YieldFrom_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
return -1;
}
- Py_INCREF(state->YieldFrom_type);
- if (PyModule_AddObject(m, "Compare", state->Compare_type) < 0) {
+ if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
return -1;
}
- Py_INCREF(state->Compare_type);
- if (PyModule_AddObject(m, "Call", state->Call_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
return -1;
}
- Py_INCREF(state->Call_type);
- if (PyModule_AddObject(m, "FormattedValue", state->FormattedValue_type) <
- 0) {
+ if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
return -1;
}
- Py_INCREF(state->FormattedValue_type);
- if (PyModule_AddObject(m, "JoinedStr", state->JoinedStr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
+ < 0) {
return -1;
}
- Py_INCREF(state->JoinedStr_type);
- if (PyModule_AddObject(m, "Constant", state->Constant_type) < 0) {
+ if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
return -1;
}
- Py_INCREF(state->Constant_type);
- if (PyModule_AddObject(m, "Attribute", state->Attribute_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
return -1;
}
- Py_INCREF(state->Attribute_type);
- if (PyModule_AddObject(m, "Subscript", state->Subscript_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
return -1;
}
- Py_INCREF(state->Subscript_type);
- if (PyModule_AddObject(m, "Starred", state->Starred_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
return -1;
}
- Py_INCREF(state->Starred_type);
- if (PyModule_AddObject(m, "Name", state->Name_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
return -1;
}
- Py_INCREF(state->Name_type);
- if (PyModule_AddObject(m, "List", state->List_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
return -1;
}
- Py_INCREF(state->List_type);
- if (PyModule_AddObject(m, "Tuple", state->Tuple_type) < 0) {
+ if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
return -1;
}
- Py_INCREF(state->Tuple_type);
- if (PyModule_AddObject(m, "Slice", state->Slice_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
return -1;
}
- Py_INCREF(state->Slice_type);
- if (PyModule_AddObject(m, "expr_context", state->expr_context_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
return -1;
}
- Py_INCREF(state->expr_context_type);
- if (PyModule_AddObject(m, "Load", state->Load_type) < 0) {
+ if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
+ {
return -1;
}
- Py_INCREF(state->Load_type);
- if (PyModule_AddObject(m, "Store", state->Store_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
return -1;
}
- Py_INCREF(state->Store_type);
- if (PyModule_AddObject(m, "Del", state->Del_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
return -1;
}
- Py_INCREF(state->Del_type);
- if (PyModule_AddObject(m, "boolop", state->boolop_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
return -1;
}
- Py_INCREF(state->boolop_type);
- if (PyModule_AddObject(m, "And", state->And_type) < 0) {
+ if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
return -1;
}
- Py_INCREF(state->And_type);
- if (PyModule_AddObject(m, "Or", state->Or_type) < 0) {
+ if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
return -1;
}
- Py_INCREF(state->Or_type);
- if (PyModule_AddObject(m, "operator", state->operator_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
return -1;
}
- Py_INCREF(state->operator_type);
- if (PyModule_AddObject(m, "Add", state->Add_type) < 0) {
+ if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
return -1;
}
- Py_INCREF(state->Add_type);
- if (PyModule_AddObject(m, "Sub", state->Sub_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
return -1;
}
- Py_INCREF(state->Sub_type);
- if (PyModule_AddObject(m, "Mult", state->Mult_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
return -1;
}
- Py_INCREF(state->Mult_type);
- if (PyModule_AddObject(m, "MatMult", state->MatMult_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
return -1;
}
- Py_INCREF(state->MatMult_type);
- if (PyModule_AddObject(m, "Div", state->Div_type) < 0) {
+ if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
return -1;
}
- Py_INCREF(state->Div_type);
- if (PyModule_AddObject(m, "Mod", state->Mod_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
return -1;
}
- Py_INCREF(state->Mod_type);
- if (PyModule_AddObject(m, "Pow", state->Pow_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
return -1;
}
- Py_INCREF(state->Pow_type);
- if (PyModule_AddObject(m, "LShift", state->LShift_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
return -1;
}
- Py_INCREF(state->LShift_type);
- if (PyModule_AddObject(m, "RShift", state->RShift_type) < 0) {
+ if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
return -1;
}
- Py_INCREF(state->RShift_type);
- if (PyModule_AddObject(m, "BitOr", state->BitOr_type) < 0) {
+ if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
return -1;
}
- Py_INCREF(state->BitOr_type);
- if (PyModule_AddObject(m, "BitXor", state->BitXor_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
return -1;
}
- Py_INCREF(state->BitXor_type);
- if (PyModule_AddObject(m, "BitAnd", state->BitAnd_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
return -1;
}
- Py_INCREF(state->BitAnd_type);
- if (PyModule_AddObject(m, "FloorDiv", state->FloorDiv_type) < 0) {
+ if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
return -1;
}
- Py_INCREF(state->FloorDiv_type);
- if (PyModule_AddObject(m, "unaryop", state->unaryop_type) < 0) {
+ if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
return -1;
}
- Py_INCREF(state->unaryop_type);
- if (PyModule_AddObject(m, "Invert", state->Invert_type) < 0) {
+ if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
return -1;
}
- Py_INCREF(state->Invert_type);
- if (PyModule_AddObject(m, "Not", state->Not_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
return -1;
}
- Py_INCREF(state->Not_type);
- if (PyModule_AddObject(m, "UAdd", state->UAdd_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
return -1;
}
- Py_INCREF(state->UAdd_type);
- if (PyModule_AddObject(m, "USub", state->USub_type) < 0) {
+ if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
return -1;
}
- Py_INCREF(state->USub_type);
- if (PyModule_AddObject(m, "cmpop", state->cmpop_type) < 0) {
+ if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
return -1;
}
- Py_INCREF(state->cmpop_type);
- if (PyModule_AddObject(m, "Eq", state->Eq_type) < 0) {
+ if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
return -1;
}
- Py_INCREF(state->Eq_type);
- if (PyModule_AddObject(m, "NotEq", state->NotEq_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
return -1;
}
- Py_INCREF(state->NotEq_type);
- if (PyModule_AddObject(m, "Lt", state->Lt_type) < 0) {
+ if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
return -1;
}
- Py_INCREF(state->Lt_type);
- if (PyModule_AddObject(m, "LtE", state->LtE_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
return -1;
}
- Py_INCREF(state->LtE_type);
- if (PyModule_AddObject(m, "Gt", state->Gt_type) < 0) {
+ if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
return -1;
}
- Py_INCREF(state->Gt_type);
- if (PyModule_AddObject(m, "GtE", state->GtE_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
return -1;
}
- Py_INCREF(state->GtE_type);
- if (PyModule_AddObject(m, "Is", state->Is_type) < 0) {
+ if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
return -1;
}
- Py_INCREF(state->Is_type);
- if (PyModule_AddObject(m, "IsNot", state->IsNot_type) < 0) {
+ if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
return -1;
}
- Py_INCREF(state->IsNot_type);
- if (PyModule_AddObject(m, "In", state->In_type) < 0) {
+ if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
return -1;
}
- Py_INCREF(state->In_type);
- if (PyModule_AddObject(m, "NotIn", state->NotIn_type) < 0) {
+ if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
return -1;
}
- Py_INCREF(state->NotIn_type);
- if (PyModule_AddObject(m, "comprehension", state->comprehension_type) < 0) {
+ if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
return -1;
}
- Py_INCREF(state->comprehension_type);
- if (PyModule_AddObject(m, "excepthandler", state->excepthandler_type) < 0) {
+ if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
+ 0) {
return -1;
}
- Py_INCREF(state->excepthandler_type);
- if (PyModule_AddObject(m, "ExceptHandler", state->ExceptHandler_type) < 0) {
+ if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
+ 0) {
return -1;
}
- Py_INCREF(state->ExceptHandler_type);
- if (PyModule_AddObject(m, "arguments", state->arguments_type) < 0) {
+ if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
+ 0) {
return -1;
}
- Py_INCREF(state->arguments_type);
- if (PyModule_AddObject(m, "arg", state->arg_type) < 0) {
+ if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
return -1;
}
- Py_INCREF(state->arg_type);
- if (PyModule_AddObject(m, "keyword", state->keyword_type) < 0) {
+ if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
return -1;
}
- Py_INCREF(state->keyword_type);
- if (PyModule_AddObject(m, "alias", state->alias_type) < 0) {
+ if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
return -1;
}
- Py_INCREF(state->alias_type);
- if (PyModule_AddObject(m, "withitem", state->withitem_type) < 0) {
+ if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
return -1;
}
- Py_INCREF(state->withitem_type);
- if (PyModule_AddObject(m, "type_ignore", state->type_ignore_type) < 0) {
+ if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
return -1;
}
- Py_INCREF(state->type_ignore_type);
- if (PyModule_AddObject(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
+ if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
+ < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
+ 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
+ {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
+ return -1;
+ }
+ if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
return -1;
}
- Py_INCREF(state->TypeIgnore_type);
return 0;
}
@@ -10787,7 +11986,7 @@ static PyModuleDef_Slot astmodule_slots[] = {
static struct PyModuleDef _astmodule = {
PyModuleDef_HEAD_INIT,
.m_name = "_ast",
- // The _ast module uses a global state (global_ast_state).
+ // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
.m_size = 0,
.m_slots = astmodule_slots,
};
@@ -10801,7 +12000,7 @@ PyInit__ast(void)
PyObject* PyAST_mod2obj(mod_ty t)
{
- astmodulestate *state = get_global_ast_state();
+ struct ast_state *state = get_ast_state();
if (state == NULL) {
return NULL;
}
@@ -10818,7 +12017,11 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
return NULL;
}
- astmodulestate *state = get_global_ast_state();
+ struct ast_state *state = get_ast_state();
+ if (state == NULL) {
+ return NULL;
+ }
+
PyObject *req_type[3];
req_type[0] = state->Module_type;
req_type[1] = state->Expression_type;
@@ -10844,7 +12047,7 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
int PyAST_Check(PyObject* obj)
{
- astmodulestate *state = get_global_ast_state();
+ struct ast_state *state = get_ast_state();
if (state == NULL) {
return -1;
}