if (*out == NULL) goto failed;
return 0;
}
+ isinstance = PyObject_IsInstance(obj, (PyObject*)FormattedValue_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ expr_ty value;
+ int conversion;
+ expr_ty format_spec;
+
+ if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_expr(tmp, &value, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
+ return 1;
+ }
+ if (exists_not_none(obj, &PyId_conversion)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_conversion);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_int(tmp, &conversion, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ conversion = 0;
+ }
+ if (exists_not_none(obj, &PyId_format_spec)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_format_spec);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_expr(tmp, &format_spec, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ format_spec = NULL;
+ }
+ *out = FormattedValue(value, conversion, format_spec, lineno,
+ col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
+ isinstance = PyObject_IsInstance(obj, (PyObject*)JoinedStr_type);
+ if (isinstance == -1) {
+ return 1;
+ }
+ if (isinstance) {
+ asdl_seq* values;
+
+ if (_PyObject_HasAttrId(obj, &PyId_values)) {
+ int res;
+ Py_ssize_t len;
+ Py_ssize_t i;
+ tmp = _PyObject_GetAttrId(obj, &PyId_values);
+ if (tmp == NULL) goto failed;
+ if (!PyList_Check(tmp)) {
+ PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
+ goto failed;
+ }
+ len = PyList_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);
+ if (res != 0) goto failed;
++ if (len != PyList_GET_SIZE(tmp)) {
++ PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
++ goto failed;
++ }
+ asdl_seq_SET(values, i, value);
+ }
+ Py_CLEAR(tmp);
+ } else {
+ PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
+ return 1;
+ }
+ *out = JoinedStr(values, lineno, col_offset, arena);
+ if (*out == NULL) goto failed;
+ return 0;
+ }
isinstance = PyObject_IsInstance(obj, (PyObject*)Bytes_type);
if (isinstance == -1) {
return 1;