mirror of https://github.com/python/cpython
bpo-40528: Improve and clear several aspects of the ASDL definition code for the AST (GH-19952)
This commit is contained in:
parent
2668a9a5aa
commit
091951a67c
|
@ -4,9 +4,7 @@
|
||||||
|
|
||||||
typedef PyObject * identifier;
|
typedef PyObject * identifier;
|
||||||
typedef PyObject * string;
|
typedef PyObject * string;
|
||||||
typedef PyObject * bytes;
|
|
||||||
typedef PyObject * object;
|
typedef PyObject * object;
|
||||||
typedef PyObject * singleton;
|
|
||||||
typedef PyObject * constant;
|
typedef PyObject * constant;
|
||||||
|
|
||||||
/* It would be nice if the code generated by asdl_c.py was completely
|
/* It would be nice if the code generated by asdl_c.py was completely
|
||||||
|
|
|
@ -597,7 +597,7 @@ class AST_Tests(unittest.TestCase):
|
||||||
empty_yield_from.body[0].body[0].value.value = None
|
empty_yield_from.body[0].body[0].value.value = None
|
||||||
with self.assertRaises(ValueError) as cm:
|
with self.assertRaises(ValueError) as cm:
|
||||||
compile(empty_yield_from, "<test>", "exec")
|
compile(empty_yield_from, "<test>", "exec")
|
||||||
self.assertIn("field value is required", str(cm.exception))
|
self.assertIn("field 'value' is required", str(cm.exception))
|
||||||
|
|
||||||
@support.cpython_only
|
@support.cpython_only
|
||||||
def test_issue31592(self):
|
def test_issue31592(self):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-- ASDL's 5 builtin types are:
|
-- ASDL's 4 builtin types are:
|
||||||
-- identifier, int, string, object, constant
|
-- identifier, int, string, constant
|
||||||
|
|
||||||
module Python
|
module Python
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,8 +33,7 @@ __all__ = [
|
||||||
# See the EBNF at the top of the file to understand the logical connection
|
# See the EBNF at the top of the file to understand the logical connection
|
||||||
# between the various node types.
|
# between the various node types.
|
||||||
|
|
||||||
builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton',
|
builtin_types = {'identifier', 'string', 'int', 'constant'}
|
||||||
'constant'}
|
|
||||||
|
|
||||||
class AST:
|
class AST:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
|
@ -323,7 +323,7 @@ class FunctionVisitor(PrototypeVisitor):
|
||||||
if not opt and argtype != "int":
|
if not opt and argtype != "int":
|
||||||
emit("if (!%s) {" % argname, 1)
|
emit("if (!%s) {" % argname, 1)
|
||||||
emit("PyErr_SetString(PyExc_ValueError,", 2)
|
emit("PyErr_SetString(PyExc_ValueError,", 2)
|
||||||
msg = "field %s is required for %s" % (argname, name)
|
msg = "field '%s' is required for %s" % (argname, name)
|
||||||
emit(' "%s");' % msg,
|
emit(' "%s");' % msg,
|
||||||
2, reflow=False)
|
2, reflow=False)
|
||||||
emit('return NULL;', 2)
|
emit('return NULL;', 2)
|
||||||
|
@ -853,11 +853,9 @@ static PyObject* ast2obj_object(void *o)
|
||||||
Py_INCREF((PyObject*)o);
|
Py_INCREF((PyObject*)o);
|
||||||
return (PyObject*)o;
|
return (PyObject*)o;
|
||||||
}
|
}
|
||||||
#define ast2obj_singleton ast2obj_object
|
|
||||||
#define ast2obj_constant ast2obj_object
|
#define ast2obj_constant ast2obj_object
|
||||||
#define ast2obj_identifier ast2obj_object
|
#define ast2obj_identifier ast2obj_object
|
||||||
#define ast2obj_string ast2obj_object
|
#define ast2obj_string ast2obj_object
|
||||||
#define ast2obj_bytes ast2obj_object
|
|
||||||
|
|
||||||
static PyObject* ast2obj_int(long b)
|
static PyObject* ast2obj_int(long b)
|
||||||
{
|
{
|
||||||
|
@ -1147,12 +1145,8 @@ class ObjVisitor(PickleVisitor):
|
||||||
self.emit("case %s:" % t.name, 2)
|
self.emit("case %s:" % t.name, 2)
|
||||||
self.emit("Py_INCREF(astmodulestate_global->%s_singleton);" % t.name, 3)
|
self.emit("Py_INCREF(astmodulestate_global->%s_singleton);" % t.name, 3)
|
||||||
self.emit("return astmodulestate_global->%s_singleton;" % t.name, 3)
|
self.emit("return astmodulestate_global->%s_singleton;" % t.name, 3)
|
||||||
self.emit("default:", 2)
|
|
||||||
self.emit('/* should never happen, but just in case ... */', 3)
|
|
||||||
code = "PyErr_Format(PyExc_SystemError, \"unknown %s found\");" % name
|
|
||||||
self.emit(code, 3, reflow=False)
|
|
||||||
self.emit("return NULL;", 3)
|
|
||||||
self.emit("}", 1)
|
self.emit("}", 1)
|
||||||
|
self.emit("Py_UNREACHABLE();", 1);
|
||||||
self.emit("}", 0)
|
self.emit("}", 0)
|
||||||
|
|
||||||
def visitProduct(self, prod, name):
|
def visitProduct(self, prod, name):
|
||||||
|
|
|
@ -1294,11 +1294,9 @@ static PyObject* ast2obj_object(void *o)
|
||||||
Py_INCREF((PyObject*)o);
|
Py_INCREF((PyObject*)o);
|
||||||
return (PyObject*)o;
|
return (PyObject*)o;
|
||||||
}
|
}
|
||||||
#define ast2obj_singleton ast2obj_object
|
|
||||||
#define ast2obj_constant ast2obj_object
|
#define ast2obj_constant ast2obj_object
|
||||||
#define ast2obj_identifier ast2obj_object
|
#define ast2obj_identifier ast2obj_object
|
||||||
#define ast2obj_string ast2obj_object
|
#define ast2obj_string ast2obj_object
|
||||||
#define ast2obj_bytes ast2obj_object
|
|
||||||
|
|
||||||
static PyObject* ast2obj_int(long b)
|
static PyObject* ast2obj_int(long b)
|
||||||
{
|
{
|
||||||
|
@ -2077,7 +2075,7 @@ Expression(expr_ty body, PyArena *arena)
|
||||||
mod_ty p;
|
mod_ty p;
|
||||||
if (!body) {
|
if (!body) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field body is required for Expression");
|
"field 'body' is required for Expression");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2094,7 +2092,7 @@ FunctionType(asdl_seq * argtypes, expr_ty returns, PyArena *arena)
|
||||||
mod_ty p;
|
mod_ty p;
|
||||||
if (!returns) {
|
if (!returns) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field returns is required for FunctionType");
|
"field 'returns' is required for FunctionType");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (mod_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2114,12 +2112,12 @@ FunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq *
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field name is required for FunctionDef");
|
"field 'name' is required for FunctionDef");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!args) {
|
if (!args) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field args is required for FunctionDef");
|
"field 'args' is required for FunctionDef");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2148,12 +2146,12 @@ AsyncFunctionDef(identifier name, arguments_ty args, asdl_seq * body, asdl_seq
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field name is required for AsyncFunctionDef");
|
"field 'name' is required for AsyncFunctionDef");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!args) {
|
if (!args) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field args is required for AsyncFunctionDef");
|
"field 'args' is required for AsyncFunctionDef");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2181,7 +2179,7 @@ ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, asdl_seq *
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field name is required for ClassDef");
|
"field 'name' is required for ClassDef");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2241,7 +2239,7 @@ Assign(asdl_seq * targets, expr_ty value, string type_comment, int lineno, int
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Assign");
|
"field 'value' is required for Assign");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2265,17 +2263,17 @@ AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field target is required for AugAssign");
|
"field 'target' is required for AugAssign");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!op) {
|
if (!op) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field op is required for AugAssign");
|
"field 'op' is required for AugAssign");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for AugAssign");
|
"field 'value' is required for AugAssign");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2300,12 +2298,12 @@ AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple, int
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field target is required for AnnAssign");
|
"field 'target' is required for AnnAssign");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!annotation) {
|
if (!annotation) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field annotation is required for AnnAssign");
|
"field 'annotation' is required for AnnAssign");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2331,12 +2329,12 @@ For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, string
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field target is required for For");
|
"field 'target' is required for For");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field iter is required for For");
|
"field 'iter' is required for For");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2363,12 +2361,12 @@ AsyncFor(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field target is required for AsyncFor");
|
"field 'target' is required for AsyncFor");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field iter is required for AsyncFor");
|
"field 'iter' is required for AsyncFor");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2394,7 +2392,7 @@ While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!test) {
|
if (!test) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field test is required for While");
|
"field 'test' is required for While");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2418,7 +2416,7 @@ If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!test) {
|
if (!test) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field test is required for If");
|
"field 'test' is required for If");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2519,7 +2517,7 @@ Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int end_lineno,
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!test) {
|
if (!test) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field test is required for Assert");
|
"field 'test' is required for Assert");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2612,7 +2610,7 @@ Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
|
||||||
stmt_ty p;
|
stmt_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Expr");
|
"field 'value' is required for Expr");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2682,7 +2680,7 @@ BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!op) {
|
if (!op) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field op is required for BoolOp");
|
"field 'op' is required for BoolOp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2705,12 +2703,12 @@ NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field target is required for NamedExpr");
|
"field 'target' is required for NamedExpr");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for NamedExpr");
|
"field 'value' is required for NamedExpr");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2733,17 +2731,17 @@ BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int col_offset,
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!left) {
|
if (!left) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field left is required for BinOp");
|
"field 'left' is required for BinOp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!op) {
|
if (!op) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field op is required for BinOp");
|
"field 'op' is required for BinOp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!right) {
|
if (!right) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field right is required for BinOp");
|
"field 'right' is required for BinOp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2767,12 +2765,12 @@ UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!op) {
|
if (!op) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field op is required for UnaryOp");
|
"field 'op' is required for UnaryOp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!operand) {
|
if (!operand) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field operand is required for UnaryOp");
|
"field 'operand' is required for UnaryOp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2795,12 +2793,12 @@ Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!args) {
|
if (!args) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field args is required for Lambda");
|
"field 'args' is required for Lambda");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!body) {
|
if (!body) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field body is required for Lambda");
|
"field 'body' is required for Lambda");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2823,17 +2821,17 @@ IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int col_offset,
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!test) {
|
if (!test) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field test is required for IfExp");
|
"field 'test' is required for IfExp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!body) {
|
if (!body) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field body is required for IfExp");
|
"field 'body' is required for IfExp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!orelse) {
|
if (!orelse) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field orelse is required for IfExp");
|
"field 'orelse' is required for IfExp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2892,7 +2890,7 @@ ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!elt) {
|
if (!elt) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field elt is required for ListComp");
|
"field 'elt' is required for ListComp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2915,7 +2913,7 @@ SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!elt) {
|
if (!elt) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field elt is required for SetComp");
|
"field 'elt' is required for SetComp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2938,12 +2936,12 @@ DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int lineno, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!key) {
|
if (!key) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field key is required for DictComp");
|
"field 'key' is required for DictComp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for DictComp");
|
"field 'value' is required for DictComp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2967,7 +2965,7 @@ GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset,
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!elt) {
|
if (!elt) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field elt is required for GeneratorExp");
|
"field 'elt' is required for GeneratorExp");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -2990,7 +2988,7 @@ Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Await");
|
"field 'value' is required for Await");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3029,7 +3027,7 @@ YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for YieldFrom");
|
"field 'value' is required for YieldFrom");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3051,7 +3049,7 @@ Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int lineno,
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!left) {
|
if (!left) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field left is required for Compare");
|
"field 'left' is required for Compare");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3075,7 +3073,7 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int lineno, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!func) {
|
if (!func) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field func is required for Call");
|
"field 'func' is required for Call");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3100,7 +3098,7 @@ FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int lineno,
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for FormattedValue");
|
"field 'value' is required for FormattedValue");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3141,7 +3139,7 @@ Constant(constant value, string kind, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Constant");
|
"field 'value' is required for Constant");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3164,17 +3162,17 @@ Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Attribute");
|
"field 'value' is required for Attribute");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!attr) {
|
if (!attr) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field attr is required for Attribute");
|
"field 'attr' is required for Attribute");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field ctx is required for Attribute");
|
"field 'ctx' is required for Attribute");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3198,17 +3196,17 @@ Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Subscript");
|
"field 'value' is required for Subscript");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!slice) {
|
if (!slice) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field slice is required for Subscript");
|
"field 'slice' is required for Subscript");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field ctx is required for Subscript");
|
"field 'ctx' is required for Subscript");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3232,12 +3230,12 @@ Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for Starred");
|
"field 'value' is required for Starred");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field ctx is required for Starred");
|
"field 'ctx' is required for Starred");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3260,12 +3258,12 @@ Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field id is required for Name");
|
"field 'id' is required for Name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field ctx is required for Name");
|
"field 'ctx' is required for Name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3288,7 +3286,7 @@ List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field ctx is required for List");
|
"field 'ctx' is required for List");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3311,7 +3309,7 @@ Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, int
|
||||||
expr_ty p;
|
expr_ty p;
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field ctx is required for Tuple");
|
"field 'ctx' is required for Tuple");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3353,12 +3351,12 @@ comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, int is_async,
|
||||||
comprehension_ty p;
|
comprehension_ty p;
|
||||||
if (!target) {
|
if (!target) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field target is required for comprehension");
|
"field 'target' is required for comprehension");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field iter is required for comprehension");
|
"field 'iter' is required for comprehension");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (comprehension_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3416,7 +3414,7 @@ arg(identifier arg, expr_ty annotation, string type_comment, int lineno, int
|
||||||
arg_ty p;
|
arg_ty p;
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field arg is required for arg");
|
"field 'arg' is required for arg");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (arg_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3439,7 +3437,7 @@ keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
|
||||||
keyword_ty p;
|
keyword_ty p;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field value is required for keyword");
|
"field 'value' is required for keyword");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (keyword_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3460,7 +3458,7 @@ alias(identifier name, identifier asname, PyArena *arena)
|
||||||
alias_ty p;
|
alias_ty p;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field name is required for alias");
|
"field 'name' is required for alias");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (alias_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3477,7 +3475,7 @@ withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
|
||||||
withitem_ty p;
|
withitem_ty p;
|
||||||
if (!context_expr) {
|
if (!context_expr) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field context_expr is required for withitem");
|
"field 'context_expr' is required for withitem");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (withitem_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -3494,7 +3492,7 @@ TypeIgnore(int lineno, string tag, PyArena *arena)
|
||||||
type_ignore_ty p;
|
type_ignore_ty p;
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"field tag is required for TypeIgnore");
|
"field 'tag' is required for TypeIgnore");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
p = (type_ignore_ty)PyArena_Malloc(arena, sizeof(*p));
|
p = (type_ignore_ty)PyArena_Malloc(arena, sizeof(*p));
|
||||||
|
@ -4602,11 +4600,8 @@ PyObject* ast2obj_expr_context(expr_context_ty o)
|
||||||
case Del:
|
case Del:
|
||||||
Py_INCREF(astmodulestate_global->Del_singleton);
|
Py_INCREF(astmodulestate_global->Del_singleton);
|
||||||
return astmodulestate_global->Del_singleton;
|
return astmodulestate_global->Del_singleton;
|
||||||
default:
|
|
||||||
/* should never happen, but just in case ... */
|
|
||||||
PyErr_Format(PyExc_SystemError, "unknown expr_context found");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
PyObject* ast2obj_boolop(boolop_ty o)
|
PyObject* ast2obj_boolop(boolop_ty o)
|
||||||
{
|
{
|
||||||
|
@ -4617,11 +4612,8 @@ PyObject* ast2obj_boolop(boolop_ty o)
|
||||||
case Or:
|
case Or:
|
||||||
Py_INCREF(astmodulestate_global->Or_singleton);
|
Py_INCREF(astmodulestate_global->Or_singleton);
|
||||||
return astmodulestate_global->Or_singleton;
|
return astmodulestate_global->Or_singleton;
|
||||||
default:
|
|
||||||
/* should never happen, but just in case ... */
|
|
||||||
PyErr_Format(PyExc_SystemError, "unknown boolop found");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
PyObject* ast2obj_operator(operator_ty o)
|
PyObject* ast2obj_operator(operator_ty o)
|
||||||
{
|
{
|
||||||
|
@ -4665,11 +4657,8 @@ PyObject* ast2obj_operator(operator_ty o)
|
||||||
case FloorDiv:
|
case FloorDiv:
|
||||||
Py_INCREF(astmodulestate_global->FloorDiv_singleton);
|
Py_INCREF(astmodulestate_global->FloorDiv_singleton);
|
||||||
return astmodulestate_global->FloorDiv_singleton;
|
return astmodulestate_global->FloorDiv_singleton;
|
||||||
default:
|
|
||||||
/* should never happen, but just in case ... */
|
|
||||||
PyErr_Format(PyExc_SystemError, "unknown operator found");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
PyObject* ast2obj_unaryop(unaryop_ty o)
|
PyObject* ast2obj_unaryop(unaryop_ty o)
|
||||||
{
|
{
|
||||||
|
@ -4686,11 +4675,8 @@ PyObject* ast2obj_unaryop(unaryop_ty o)
|
||||||
case USub:
|
case USub:
|
||||||
Py_INCREF(astmodulestate_global->USub_singleton);
|
Py_INCREF(astmodulestate_global->USub_singleton);
|
||||||
return astmodulestate_global->USub_singleton;
|
return astmodulestate_global->USub_singleton;
|
||||||
default:
|
|
||||||
/* should never happen, but just in case ... */
|
|
||||||
PyErr_Format(PyExc_SystemError, "unknown unaryop found");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
PyObject* ast2obj_cmpop(cmpop_ty o)
|
PyObject* ast2obj_cmpop(cmpop_ty o)
|
||||||
{
|
{
|
||||||
|
@ -4725,11 +4711,8 @@ PyObject* ast2obj_cmpop(cmpop_ty o)
|
||||||
case NotIn:
|
case NotIn:
|
||||||
Py_INCREF(astmodulestate_global->NotIn_singleton);
|
Py_INCREF(astmodulestate_global->NotIn_singleton);
|
||||||
return astmodulestate_global->NotIn_singleton;
|
return astmodulestate_global->NotIn_singleton;
|
||||||
default:
|
|
||||||
/* should never happen, but just in case ... */
|
|
||||||
PyErr_Format(PyExc_SystemError, "unknown cmpop found");
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
PyObject*
|
PyObject*
|
||||||
ast2obj_comprehension(void* _o)
|
ast2obj_comprehension(void* _o)
|
||||||
|
|
Loading…
Reference in New Issue