diff -r 0db4403e62c4 Parser/asdl_c.py --- a/Parser/asdl_c.py Tue Sep 27 05:10:40 2016 +0000 +++ b/Parser/asdl_c.py Tue Sep 27 11:08:46 2016 +0300 @@ -505,6 +505,7 @@ class Obj2ModVisitor(PickleVisitor): if field.seq: self.emit("Py_ssize_t len;", depth+1) self.emit("Py_ssize_t i;", depth+1) + self.emit("PyObject *tmp2;", depth+1) self.emit("tmp = _PyObject_GetAttrId(obj, &PyId_%s);" % field.name, depth+1) self.emit("if (tmp == NULL) goto failed;", depth+1) if field.seq: @@ -515,7 +516,10 @@ class Obj2ModVisitor(PickleVisitor): depth+2, reflow=False) self.emit("goto failed;", depth+2) self.emit("}", depth+1) - self.emit("len = PyList_GET_SIZE(tmp);", depth+1) + self.emit("tmp2 = PyList_AsTuple(tmp);", depth+1) + self.emit("if (tmp2 == NULL) goto failed;", depth+1) + self.emit("tmp = tmp2;", depth+1) + self.emit("len = PyTuple_GET_SIZE(tmp);", depth+1) if self.isSimpleType(field): self.emit("%s = _Py_asdl_int_seq_new(len, arena);" % field.name, depth+1) else: @@ -523,7 +527,7 @@ class Obj2ModVisitor(PickleVisitor): self.emit("if (%s == NULL) goto failed;" % field.name, depth+1) self.emit("for (i = 0; i < len; i++) {", depth+1) self.emit("%s value;" % ctype, depth+2) - self.emit("res = obj2ast_%s(PyList_GET_ITEM(tmp, i), &value, arena);" % + self.emit("res = obj2ast_%s(PyTuple_GET_ITEM(tmp, i), &value, arena);" % field.type, depth+2, reflow=False) self.emit("if (res != 0) goto failed;", depth+2) self.emit("asdl_seq_SET(%s, i, value);" % field.name, depth+2) diff -r 0db4403e62c4 Python/Python-ast.c --- a/Python/Python-ast.c Tue Sep 27 05:10:40 2016 +0000 +++ b/Python/Python-ast.c Tue Sep 27 11:08:46 2016 +0300 @@ -3784,18 +3784,22 @@ obj2ast_mod(PyObject* obj, mod_ty* out, int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -3819,18 +3823,22 @@ obj2ast_mod(PyObject* obj, mod_ty* out, int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -3876,18 +3884,22 @@ obj2ast_mod(PyObject* obj, mod_ty* out, int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Suite field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -3979,18 +3991,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4003,18 +4019,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); decorator_list = _Py_asdl_seq_new(len, arena); if (decorator_list == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(decorator_list, i, value); } @@ -4075,18 +4095,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4099,18 +4123,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); decorator_list = _Py_asdl_seq_new(len, arena); if (decorator_list == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(decorator_list, i, value); } @@ -4160,18 +4188,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_bases); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); bases = _Py_asdl_seq_new(len, arena); if (bases == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(bases, i, value); } @@ -4184,18 +4216,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_keywords); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); keywords = _Py_asdl_seq_new(len, arena); if (keywords == NULL) goto failed; for (i = 0; i < len; i++) { keyword_ty value; - res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_keyword(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(keywords, i, value); } @@ -4208,18 +4244,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4232,18 +4272,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); decorator_list = _Py_asdl_seq_new(len, arena); if (decorator_list == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(decorator_list, i, value); } @@ -4289,18 +4333,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_targets); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); targets = _Py_asdl_seq_new(len, arena); if (targets == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(targets, i, value); } @@ -4325,18 +4373,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_targets); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); targets = _Py_asdl_seq_new(len, arena); if (targets == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(targets, i, value); } @@ -4442,18 +4494,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4466,18 +4522,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_orelse); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); orelse = _Py_asdl_seq_new(len, arena); if (orelse == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } @@ -4526,18 +4586,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4550,18 +4614,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_orelse); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); orelse = _Py_asdl_seq_new(len, arena); if (orelse == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } @@ -4598,18 +4666,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4622,18 +4694,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_orelse); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); orelse = _Py_asdl_seq_new(len, arena); if (orelse == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } @@ -4670,18 +4746,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4694,18 +4774,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_orelse); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); orelse = _Py_asdl_seq_new(len, arena); if (orelse == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } @@ -4730,18 +4814,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_items); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); items = _Py_asdl_seq_new(len, arena); if (items == NULL) goto failed; for (i = 0; i < len; i++) { withitem_ty value; - res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_withitem(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(items, i, value); } @@ -4754,18 +4842,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4790,18 +4882,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_items); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); items = _Py_asdl_seq_new(len, arena); if (items == NULL) goto failed; for (i = 0; i < len; i++) { withitem_ty value; - res = obj2ast_withitem(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_withitem(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(items, i, value); } @@ -4814,18 +4910,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4884,18 +4984,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -4908,18 +5012,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_handlers); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); handlers = _Py_asdl_seq_new(len, arena); if (handlers == NULL) goto failed; for (i = 0; i < len; i++) { excepthandler_ty value; - res = obj2ast_excepthandler(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_excepthandler(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(handlers, i, value); } @@ -4932,18 +5040,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_orelse); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); orelse = _Py_asdl_seq_new(len, arena); if (orelse == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(orelse, i, value); } @@ -4956,18 +5068,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_finalbody); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); finalbody = _Py_asdl_seq_new(len, arena); if (finalbody == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(finalbody, i, value); } @@ -5025,18 +5141,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_names); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); names = _Py_asdl_seq_new(len, arena); if (names == NULL) goto failed; for (i = 0; i < len; i++) { alias_ty value; - res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_alias(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(names, i, value); } @@ -5072,18 +5192,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_names); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); names = _Py_asdl_seq_new(len, arena); if (names == NULL) goto failed; for (i = 0; i < len; i++) { alias_ty value; - res = obj2ast_alias(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_alias(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(names, i, value); } @@ -5117,18 +5241,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_names); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); names = _Py_asdl_seq_new(len, arena); if (names == NULL) goto failed; for (i = 0; i < len; i++) { identifier value; - res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_identifier(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(names, i, value); } @@ -5152,18 +5280,22 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_names); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); names = _Py_asdl_seq_new(len, arena); if (names == NULL) goto failed; for (i = 0; i < len; i++) { identifier value; - res = obj2ast_identifier(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_identifier(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(names, i, value); } @@ -5293,18 +5425,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_values); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); values = _Py_asdl_seq_new(len, arena); if (values == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(values, i, value); } @@ -5489,18 +5625,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_keys); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); keys = _Py_asdl_seq_new(len, arena); if (keys == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(keys, i, value); } @@ -5513,18 +5653,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_values); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); values = _Py_asdl_seq_new(len, arena); if (values == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(values, i, value); } @@ -5548,18 +5692,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_elts); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); elts = _Py_asdl_seq_new(len, arena); if (elts == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(elts, i, value); } @@ -5595,18 +5743,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_generators); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); generators = _Py_asdl_seq_new(len, arena); if (generators == NULL) goto failed; for (i = 0; i < len; i++) { comprehension_ty value; - res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_comprehension(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } @@ -5642,18 +5794,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_generators); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); generators = _Py_asdl_seq_new(len, arena); if (generators == NULL) goto failed; for (i = 0; i < len; i++) { comprehension_ty value; - res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_comprehension(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } @@ -5701,18 +5857,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_generators); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); generators = _Py_asdl_seq_new(len, arena); if (generators == NULL) goto failed; for (i = 0; i < len; i++) { comprehension_ty value; - res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_comprehension(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } @@ -5748,18 +5908,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_generators); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); generators = _Py_asdl_seq_new(len, arena); if (generators == NULL) goto failed; for (i = 0; i < len; i++) { comprehension_ty value; - res = obj2ast_comprehension(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_comprehension(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(generators, i, value); } @@ -5861,18 +6025,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_ops); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); ops = _Py_asdl_int_seq_new(len, arena); if (ops == NULL) goto failed; for (i = 0; i < len; i++) { cmpop_ty value; - res = obj2ast_cmpop(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_cmpop(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(ops, i, value); } @@ -5885,18 +6053,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_comparators); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); comparators = _Py_asdl_seq_new(len, arena); if (comparators == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(comparators, i, value); } @@ -5933,18 +6105,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_args); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); args = _Py_asdl_seq_new(len, arena); if (args == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(args, i, value); } @@ -5957,18 +6133,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_keywords); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); keywords = _Py_asdl_seq_new(len, arena); if (keywords == NULL) goto failed; for (i = 0; i < len; i++) { keyword_ty value; - res = obj2ast_keyword(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_keyword(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(keywords, i, value); } @@ -6251,18 +6431,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_elts); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); elts = _Py_asdl_seq_new(len, arena); if (elts == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(elts, i, value); } @@ -6298,18 +6482,22 @@ obj2ast_expr(PyObject* obj, expr_ty* out int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_elts); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); elts = _Py_asdl_seq_new(len, arena); if (elts == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(elts, i, value); } @@ -6463,18 +6651,22 @@ obj2ast_slice(PyObject* obj, slice_ty* o int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_dims); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ExtSlice field \"dims\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); dims = _Py_asdl_seq_new(len, arena); if (dims == NULL) goto failed; for (i = 0; i < len; i++) { slice_ty value; - res = obj2ast_slice(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_slice(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(dims, i, value); } @@ -6822,18 +7014,22 @@ obj2ast_comprehension(PyObject* obj, com int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_ifs); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); ifs = _Py_asdl_seq_new(len, arena); if (ifs == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(ifs, i, value); } @@ -6917,18 +7113,22 @@ obj2ast_excepthandler(PyObject* obj, exc int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_body); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); body = _Py_asdl_seq_new(len, arena); if (body == NULL) goto failed; for (i = 0; i < len; i++) { stmt_ty value; - res = obj2ast_stmt(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_stmt(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(body, i, value); } @@ -6963,18 +7163,22 @@ obj2ast_arguments(PyObject* obj, argumen int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_args); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); args = _Py_asdl_seq_new(len, arena); if (args == NULL) goto failed; for (i = 0; i < len; i++) { arg_ty value; - res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_arg(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(args, i, value); } @@ -6997,18 +7201,22 @@ obj2ast_arguments(PyObject* obj, argumen int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); kwonlyargs = _Py_asdl_seq_new(len, arena); if (kwonlyargs == NULL) goto failed; for (i = 0; i < len; i++) { arg_ty value; - res = obj2ast_arg(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_arg(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(kwonlyargs, i, value); } @@ -7021,18 +7229,22 @@ obj2ast_arguments(PyObject* obj, argumen int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); kw_defaults = _Py_asdl_seq_new(len, arena); if (kw_defaults == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(kw_defaults, i, value); } @@ -7055,18 +7267,22 @@ obj2ast_arguments(PyObject* obj, argumen int res; Py_ssize_t len; Py_ssize_t i; + PyObject *tmp2; tmp = _PyObject_GetAttrId(obj, &PyId_defaults); if (tmp == NULL) goto failed; if (!PyList_Check(tmp)) { PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", tmp->ob_type->tp_name); goto failed; } - len = PyList_GET_SIZE(tmp); + tmp2 = PyList_AsTuple(tmp); + if (tmp2 == NULL) goto failed; + tmp = tmp2; + len = PyTuple_GET_SIZE(tmp); defaults = _Py_asdl_seq_new(len, arena); if (defaults == NULL) goto failed; for (i = 0; i < len; i++) { expr_ty value; - res = obj2ast_expr(PyList_GET_ITEM(tmp, i), &value, arena); + res = obj2ast_expr(PyTuple_GET_ITEM(tmp, i), &value, arena); if (res != 0) goto failed; asdl_seq_SET(defaults, i, value); }