summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-07 18:51:28 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-07 18:51:28 (GMT)
commitcf3806026b4f9784f97fce168695c3b4a6bbd8a5 (patch)
tree5819771988e418058920612ec19a6c83dc1e8013
parent36e7e97d621863e6e3e3baeb22909ec06e720639 (diff)
downloadcpython-cf3806026b4f9784f97fce168695c3b4a6bbd8a5.zip
cpython-cf3806026b4f9784f97fce168695c3b4a6bbd8a5.tar.gz
cpython-cf3806026b4f9784f97fce168695c3b4a6bbd8a5.tar.bz2
Issue #24098: Fixed possible crash when AST is changed in process of
compiling it.
-rw-r--r--Misc/NEWS3
-rwxr-xr-xParser/asdl_c.py7
-rw-r--r--Python/Python-ast.c216
3 files changed, 226 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 2da5058..369aa8b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Release date: TBA
Core and Builtins
-----------------
+- Issue #24098: Fixed possible crash when AST is changed in process of
+ compiling it.
+
- Issue #28350: String constants with null character no longer interned.
- Issue #26617: Fix crash when GC runs during weakref callbacks.
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index f38c253..ac9d2b6 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -526,6 +526,13 @@ class Obj2ModVisitor(PickleVisitor):
self.emit("res = obj2ast_%s(PyList_GET_ITEM(tmp, i), &value, arena);" %
field.type, depth+2, reflow=False)
self.emit("if (res != 0) goto failed;", depth+2)
+ self.emit("if (len != PyList_GET_SIZE(tmp)) {", depth+2)
+ self.emit("PyErr_SetString(PyExc_RuntimeError, \"%s field \\\"%s\\\" "
+ "changed size during iteration\");" %
+ (name, field.name),
+ depth+3, reflow=False)
+ self.emit("goto failed;", depth+3)
+ self.emit("}", depth+2)
self.emit("asdl_seq_SET(%s, i, value);" % field.name, depth+2)
self.emit("}", depth+1)
else:
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index edfcbad..ad53ba35 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -3797,6 +3797,10 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -3832,6 +3836,10 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -3889,6 +3897,10 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Suite field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -3992,6 +4004,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4016,6 +4032,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(decorator_list, i, value);
}
Py_CLEAR(tmp);
@@ -4088,6 +4108,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4112,6 +4136,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(decorator_list, i, value);
}
Py_CLEAR(tmp);
@@ -4173,6 +4201,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(bases, i, value);
}
Py_CLEAR(tmp);
@@ -4197,6 +4229,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
keyword_ty value;
res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(keywords, i, value);
}
Py_CLEAR(tmp);
@@ -4221,6 +4257,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4245,6 +4285,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(decorator_list, i, value);
}
Py_CLEAR(tmp);
@@ -4302,6 +4346,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(targets, i, value);
}
Py_CLEAR(tmp);
@@ -4338,6 +4386,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(targets, i, value);
}
Py_CLEAR(tmp);
@@ -4455,6 +4507,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4479,6 +4535,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(orelse, i, value);
}
Py_CLEAR(tmp);
@@ -4539,6 +4599,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4563,6 +4627,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(orelse, i, value);
}
Py_CLEAR(tmp);
@@ -4611,6 +4679,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4635,6 +4707,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(orelse, i, value);
}
Py_CLEAR(tmp);
@@ -4683,6 +4759,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4707,6 +4787,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(orelse, i, value);
}
Py_CLEAR(tmp);
@@ -4743,6 +4827,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
withitem_ty value;
res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(items, i, value);
}
Py_CLEAR(tmp);
@@ -4767,6 +4855,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4803,6 +4895,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
withitem_ty value;
res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(items, i, value);
}
Py_CLEAR(tmp);
@@ -4827,6 +4923,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4897,6 +4997,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -4921,6 +5025,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
excepthandler_ty value;
res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(handlers, i, value);
}
Py_CLEAR(tmp);
@@ -4945,6 +5053,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(orelse, i, value);
}
Py_CLEAR(tmp);
@@ -4969,6 +5081,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(finalbody, i, value);
}
Py_CLEAR(tmp);
@@ -5038,6 +5154,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
alias_ty value;
res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(names, i, value);
}
Py_CLEAR(tmp);
@@ -5085,6 +5205,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
alias_ty value;
res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(names, i, value);
}
Py_CLEAR(tmp);
@@ -5130,6 +5254,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
identifier value;
res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(names, i, value);
}
Py_CLEAR(tmp);
@@ -5165,6 +5293,10 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
identifier value;
res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(names, i, value);
}
Py_CLEAR(tmp);
@@ -5306,6 +5438,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(values, i, value);
}
Py_CLEAR(tmp);
@@ -5502,6 +5638,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(keys, i, value);
}
Py_CLEAR(tmp);
@@ -5526,6 +5666,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(values, i, value);
}
Py_CLEAR(tmp);
@@ -5561,6 +5705,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(elts, i, value);
}
Py_CLEAR(tmp);
@@ -5608,6 +5756,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
comprehension_ty value;
res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(generators, i, value);
}
Py_CLEAR(tmp);
@@ -5655,6 +5807,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
comprehension_ty value;
res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(generators, i, value);
}
Py_CLEAR(tmp);
@@ -5714,6 +5870,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
comprehension_ty value;
res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(generators, i, value);
}
Py_CLEAR(tmp);
@@ -5761,6 +5921,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
comprehension_ty value;
res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(generators, i, value);
}
Py_CLEAR(tmp);
@@ -5874,6 +6038,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
cmpop_ty value;
res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(ops, i, value);
}
Py_CLEAR(tmp);
@@ -5898,6 +6066,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(comparators, i, value);
}
Py_CLEAR(tmp);
@@ -5946,6 +6118,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(args, i, value);
}
Py_CLEAR(tmp);
@@ -5970,6 +6146,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
keyword_ty value;
res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(keywords, i, value);
}
Py_CLEAR(tmp);
@@ -6264,6 +6444,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(elts, i, value);
}
Py_CLEAR(tmp);
@@ -6311,6 +6495,10 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(elts, i, value);
}
Py_CLEAR(tmp);
@@ -6476,6 +6664,10 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
slice_ty value;
res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ExtSlice field \"dims\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(dims, i, value);
}
Py_CLEAR(tmp);
@@ -6835,6 +7027,10 @@ obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(ifs, i, value);
}
Py_CLEAR(tmp);
@@ -6930,6 +7126,10 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
stmt_ty value;
res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(body, i, value);
}
Py_CLEAR(tmp);
@@ -6976,6 +7176,10 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
arg_ty value;
res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(args, i, value);
}
Py_CLEAR(tmp);
@@ -7010,6 +7214,10 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
arg_ty value;
res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(kwonlyargs, i, value);
}
Py_CLEAR(tmp);
@@ -7034,6 +7242,10 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(kw_defaults, i, value);
}
Py_CLEAR(tmp);
@@ -7068,6 +7280,10 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
expr_ty value;
res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena);
if (res != 0) goto failed;
+ if (len != PyList_GET_SIZE(tmp)) {
+ PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
+ goto failed;
+ }
asdl_seq_SET(defaults, i, value);
}
Py_CLEAR(tmp);