int res = -1;
PyObject *key, *value, *fields;
fields = _PyObject_GetAttrId((PyObject*)Py_TYPE(self), &PyId__fields);
- if (!fields)
- PyErr_Clear();
if (fields) {
numfields = PySequence_Size(fields);
if (numfields == -1)
goto cleanup;
}
+ else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_Clear();
+ }
+ else {
+ goto cleanup;
+ }
res = 0; /* if no error occurs, this stays 0 to the end */
if (numfields < PyTuple_GET_SIZE(args)) {
return 0;
}
-static int exists_not_none(PyObject *obj, _Py_Identifier *id)
+static PyObject *get_not_none(PyObject *obj, _Py_Identifier *id)
{
- int isnone;
PyObject *attr = _PyObject_GetAttrId(obj, id);
if (!attr) {
- PyErr_Clear();
- return 0;
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_Clear();
+ }
+ return NULL;
}
- isnone = attr == Py_None;
- Py_DECREF(attr);
- return !isnone;
+ else if (attr == Py_None) {
+ Py_DECREF(attr);
+ return NULL;
+ }
+ return attr;
}
asdl_seq* body;
string docstring;
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_docstring)) {
+ tmp = get_not_none(obj, &PyId_docstring);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_docstring);
- if (tmp == NULL) goto failed;
res = obj2ast_string(tmp, &docstring, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
docstring = NULL;
}
if (isinstance) {
asdl_seq* body;
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
+ }
return 1;
}
*out = Interactive(body, arena);
if (isinstance) {
expr_ty body;
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_body);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &body, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
+ }
return 1;
}
*out = Expression(body, arena);
if (isinstance) {
asdl_seq* body;
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
+ }
return 1;
}
*out = Suite(body, arena);
*out = NULL;
return 0;
}
- if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &lineno, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &col_offset, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
+ }
return 1;
}
isinstance = PyObject_IsInstance(obj, (PyObject*)FunctionDef_type);
expr_ty returns;
string docstring;
- if (_PyObject_HasAttrId(obj, &PyId_name)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_name);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_name);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &name, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_args)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_args);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_args);
- if (tmp == NULL) goto failed;
res = obj2ast_arguments(tmp, &args, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_returns)) {
+ tmp = get_not_none(obj, &PyId_returns);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_returns);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &returns, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
returns = NULL;
}
- if (exists_not_none(obj, &PyId_docstring)) {
+ tmp = get_not_none(obj, &PyId_docstring);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_docstring);
- if (tmp == NULL) goto failed;
res = obj2ast_string(tmp, &docstring, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
docstring = NULL;
}
expr_ty returns;
string docstring;
- if (_PyObject_HasAttrId(obj, &PyId_name)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_name);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_name);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &name, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_args)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_args);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_args);
- if (tmp == NULL) goto failed;
res = obj2ast_arguments(tmp, &args, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFunctionDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from AsyncFunctionDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from AsyncFunctionDef");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_returns)) {
+ tmp = get_not_none(obj, &PyId_returns);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_returns);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &returns, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
returns = NULL;
}
- if (exists_not_none(obj, &PyId_docstring)) {
+ tmp = get_not_none(obj, &PyId_docstring);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_docstring);
- if (tmp == NULL) goto failed;
res = obj2ast_string(tmp, &docstring, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
docstring = NULL;
}
asdl_seq* decorator_list;
string docstring;
- if (_PyObject_HasAttrId(obj, &PyId_name)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_name);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_name);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &name, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_bases)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_bases);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_decorator_list)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_decorator_list);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_docstring)) {
+ tmp = get_not_none(obj, &PyId_docstring);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_docstring);
- if (tmp == NULL) goto failed;
res = obj2ast_string(tmp, &docstring, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
docstring = NULL;
}
if (isinstance) {
expr_ty value;
- if (exists_not_none(obj, &PyId_value)) {
+ tmp = get_not_none(obj, &PyId_value);
+ if (tmp != NULL) {
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 if (PyErr_Occurred()) {
+ return 1;
} else {
value = NULL;
}
if (isinstance) {
asdl_seq* targets;
- if (_PyObject_HasAttrId(obj, &PyId_targets)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_targets);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
+ }
return 1;
}
*out = Delete(targets, lineno, col_offset, arena);
asdl_seq* targets;
expr_ty value;
- if (_PyObject_HasAttrId(obj, &PyId_targets)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_targets);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Assign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
+ }
return 1;
}
*out = Assign(targets, value, lineno, col_offset, arena);
operator_ty op;
expr_ty value;
- if (_PyObject_HasAttrId(obj, &PyId_target)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_target);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_target);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &target, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_op)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_op);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_op);
- if (tmp == NULL) goto failed;
res = obj2ast_operator(tmp, &op, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 AugAssign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
+ }
return 1;
}
*out = AugAssign(target, op, value, lineno, col_offset, arena);
expr_ty value;
int simple;
- if (_PyObject_HasAttrId(obj, &PyId_target)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_target);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_target);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &target, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_annotation)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_annotation);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_annotation);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &annotation, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_value)) {
+ tmp = get_not_none(obj, &PyId_value);
+ if (tmp != NULL) {
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 if (PyErr_Occurred()) {
+ return 1;
} else {
value = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_simple)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_simple);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_simple);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &simple, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
+ }
return 1;
}
*out = AnnAssign(target, annotation, value, simple, lineno, col_offset,
asdl_seq* body;
asdl_seq* orelse;
- if (_PyObject_HasAttrId(obj, &PyId_target)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_target);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_target);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &target, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_iter)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_iter);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_iter);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &iter, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
+ }
return 1;
}
*out = For(target, iter, body, orelse, lineno, col_offset, arena);
asdl_seq* body;
asdl_seq* orelse;
- if (_PyObject_HasAttrId(obj, &PyId_target)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_target);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_target);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &target, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_iter)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_iter);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_iter);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &iter, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFor");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncFor");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from AsyncFor");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from AsyncFor");
+ }
return 1;
}
*out = AsyncFor(target, iter, body, orelse, lineno, col_offset, arena);
asdl_seq* body;
asdl_seq* orelse;
- if (_PyObject_HasAttrId(obj, &PyId_test)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_test);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_test);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &test, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
+ }
return 1;
}
*out = While(test, body, orelse, lineno, col_offset, arena);
asdl_seq* body;
asdl_seq* orelse;
- if (_PyObject_HasAttrId(obj, &PyId_test)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_test);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_test);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &test, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
+ }
return 1;
}
*out = If(test, body, orelse, lineno, col_offset, arena);
asdl_seq* items;
asdl_seq* body;
- if (_PyObject_HasAttrId(obj, &PyId_items)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_items);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
+ }
return 1;
}
*out = With(items, body, lineno, col_offset, arena);
asdl_seq* items;
asdl_seq* body;
- if (_PyObject_HasAttrId(obj, &PyId_items)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_items);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from AsyncWith");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from AsyncWith");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncWith");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from AsyncWith");
+ }
return 1;
}
*out = AsyncWith(items, body, lineno, col_offset, arena);
expr_ty exc;
expr_ty cause;
- if (exists_not_none(obj, &PyId_exc)) {
+ tmp = get_not_none(obj, &PyId_exc);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_exc);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &exc, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
exc = NULL;
}
- if (exists_not_none(obj, &PyId_cause)) {
+ tmp = get_not_none(obj, &PyId_cause);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_cause);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &cause, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
cause = NULL;
}
asdl_seq* orelse;
asdl_seq* finalbody;
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_handlers)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_handlers);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_finalbody)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_finalbody);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
+ }
return 1;
}
*out = Try(body, handlers, orelse, finalbody, lineno, col_offset,
expr_ty test;
expr_ty msg;
- if (_PyObject_HasAttrId(obj, &PyId_test)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_test);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_test);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &test, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_msg)) {
+ tmp = get_not_none(obj, &PyId_msg);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_msg);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &msg, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
msg = NULL;
}
if (isinstance) {
asdl_seq* names;
- if (_PyObject_HasAttrId(obj, &PyId_names)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_names);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
+ }
return 1;
}
*out = Import(names, lineno, col_offset, arena);
asdl_seq* names;
int level;
- if (exists_not_none(obj, &PyId_module)) {
+ tmp = get_not_none(obj, &PyId_module);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_module);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &module, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
module = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_names)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_names);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_level)) {
+ tmp = get_not_none(obj, &PyId_level);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_level);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &level, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
level = 0;
}
if (isinstance) {
asdl_seq* names;
- if (_PyObject_HasAttrId(obj, &PyId_names)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_names);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
+ }
return 1;
}
*out = Global(names, lineno, col_offset, arena);
if (isinstance) {
asdl_seq* names;
- if (_PyObject_HasAttrId(obj, &PyId_names)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_names);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
+ }
return 1;
}
*out = Nonlocal(names, lineno, col_offset, arena);
if (isinstance) {
expr_ty value;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Expr");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
+ }
return 1;
}
*out = Expr(value, lineno, col_offset, arena);
*out = NULL;
return 0;
}
- if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &lineno, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &col_offset, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
+ }
return 1;
}
isinstance = PyObject_IsInstance(obj, (PyObject*)BoolOp_type);
boolop_ty op;
asdl_seq* values;
- if (_PyObject_HasAttrId(obj, &PyId_op)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_op);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_op);
- if (tmp == NULL) goto failed;
res = obj2ast_boolop(tmp, &op, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_values)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_values);
+ if (tmp != NULL) {
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, "BoolOp field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
goto failed;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
+ }
return 1;
}
*out = BoolOp(op, values, lineno, col_offset, arena);
operator_ty op;
expr_ty right;
- if (_PyObject_HasAttrId(obj, &PyId_left)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_left);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_left);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &left, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_op)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_op);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_op);
- if (tmp == NULL) goto failed;
res = obj2ast_operator(tmp, &op, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_right)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_right);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_right);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &right, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
+ }
return 1;
}
*out = BinOp(left, op, right, lineno, col_offset, arena);
unaryop_ty op;
expr_ty operand;
- if (_PyObject_HasAttrId(obj, &PyId_op)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_op);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_op);
- if (tmp == NULL) goto failed;
res = obj2ast_unaryop(tmp, &op, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_operand)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_operand);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_operand);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &operand, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
+ }
return 1;
}
*out = UnaryOp(op, operand, lineno, col_offset, arena);
arguments_ty args;
expr_ty body;
- if (_PyObject_HasAttrId(obj, &PyId_args)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_args);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_args);
- if (tmp == NULL) goto failed;
res = obj2ast_arguments(tmp, &args, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_body);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &body, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
+ }
return 1;
}
*out = Lambda(args, body, lineno, col_offset, arena);
expr_ty body;
expr_ty orelse;
- if (_PyObject_HasAttrId(obj, &PyId_test)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_test);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_test);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &test, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_body);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &body, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_orelse)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_orelse);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &orelse, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
+ }
return 1;
}
*out = IfExp(test, body, orelse, lineno, col_offset, arena);
asdl_seq* keys;
asdl_seq* values;
- if (_PyObject_HasAttrId(obj, &PyId_keys)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_keys);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_values)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_values);
+ if (tmp != NULL) {
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, "Dict field \"values\" must be a list, not a %.200s", tmp->ob_type->tp_name);
goto failed;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
+ }
return 1;
}
*out = Dict(keys, values, lineno, col_offset, arena);
if (isinstance) {
asdl_seq* elts;
- if (_PyObject_HasAttrId(obj, &PyId_elts)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_elts);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
+ }
return 1;
}
*out = Set(elts, lineno, col_offset, arena);
expr_ty elt;
asdl_seq* generators;
- if (_PyObject_HasAttrId(obj, &PyId_elt)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_elt);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_elt);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &elt, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_generators)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_generators);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
+ }
return 1;
}
*out = ListComp(elt, generators, lineno, col_offset, arena);
expr_ty elt;
asdl_seq* generators;
- if (_PyObject_HasAttrId(obj, &PyId_elt)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_elt);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_elt);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &elt, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_generators)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_generators);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
+ }
return 1;
}
*out = SetComp(elt, generators, lineno, col_offset, arena);
expr_ty value;
asdl_seq* generators;
- if (_PyObject_HasAttrId(obj, &PyId_key)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_key);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_key);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &key, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 DictComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_generators)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_generators);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
+ }
return 1;
}
*out = DictComp(key, value, generators, lineno, col_offset, arena);
expr_ty elt;
asdl_seq* generators;
- if (_PyObject_HasAttrId(obj, &PyId_elt)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_elt);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_elt);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &elt, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_generators)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_generators);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
+ }
return 1;
}
*out = GeneratorExp(elt, generators, lineno, col_offset, arena);
if (isinstance) {
expr_ty value;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Await");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
+ }
return 1;
}
*out = Await(value, lineno, col_offset, arena);
if (isinstance) {
expr_ty value;
- if (exists_not_none(obj, &PyId_value)) {
+ tmp = get_not_none(obj, &PyId_value);
+ if (tmp != NULL) {
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 if (PyErr_Occurred()) {
+ return 1;
} else {
value = NULL;
}
if (isinstance) {
expr_ty value;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 YieldFrom");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
+ }
return 1;
}
*out = YieldFrom(value, lineno, col_offset, arena);
asdl_int_seq* ops;
asdl_seq* comparators;
- if (_PyObject_HasAttrId(obj, &PyId_left)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_left);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_left);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &left, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ops)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ops);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_comparators)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_comparators);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
+ }
return 1;
}
*out = Compare(left, ops, comparators, lineno, col_offset, arena);
asdl_seq* args;
asdl_seq* keywords;
- if (_PyObject_HasAttrId(obj, &PyId_func)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_func);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_func);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &func, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_args)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_args);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_keywords)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_keywords);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
+ }
return 1;
}
*out = Call(func, args, keywords, lineno, col_offset, arena);
if (isinstance) {
object n;
- if (_PyObject_HasAttrId(obj, &PyId_n)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_n);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_n);
- if (tmp == NULL) goto failed;
res = obj2ast_object(tmp, &n, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
+ }
return 1;
}
*out = Num(n, lineno, col_offset, arena);
if (isinstance) {
string s;
- if (_PyObject_HasAttrId(obj, &PyId_s)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_s);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_s);
- if (tmp == NULL) goto failed;
res = obj2ast_string(tmp, &s, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
+ }
return 1;
}
*out = Str(s, lineno, col_offset, arena);
int conversion;
expr_ty format_spec;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_conversion)) {
+ tmp = get_not_none(obj, &PyId_conversion);
+ if (tmp != NULL) {
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 if (PyErr_Occurred()) {
+ return 1;
} else {
conversion = 0;
}
- if (exists_not_none(obj, &PyId_format_spec)) {
+ tmp = get_not_none(obj, &PyId_format_spec);
+ if (tmp != NULL) {
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 if (PyErr_Occurred()) {
+ return 1;
} else {
format_spec = NULL;
}
if (isinstance) {
asdl_seq* values;
- if (_PyObject_HasAttrId(obj, &PyId_values)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_values);
+ if (tmp != NULL) {
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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from JoinedStr");
+ }
return 1;
}
*out = JoinedStr(values, lineno, col_offset, arena);
if (isinstance) {
bytes s;
- if (_PyObject_HasAttrId(obj, &PyId_s)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_s);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_s);
- if (tmp == NULL) goto failed;
res = obj2ast_bytes(tmp, &s, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
+ }
return 1;
}
*out = Bytes(s, lineno, col_offset, arena);
if (isinstance) {
singleton value;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_value);
- if (tmp == NULL) goto failed;
res = obj2ast_singleton(tmp, &value, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NameConstant");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NameConstant");
+ }
return 1;
}
*out = NameConstant(value, lineno, col_offset, arena);
if (isinstance) {
constant value;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_value);
- if (tmp == NULL) goto failed;
res = obj2ast_constant(tmp, &value, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
+ }
return 1;
}
*out = Constant(value, lineno, col_offset, arena);
identifier attr;
expr_context_ty ctx;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Attribute");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_attr)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_attr);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_attr);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &attr, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
- if (tmp == NULL) goto failed;
res = obj2ast_expr_context(tmp, &ctx, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
+ }
return 1;
}
*out = Attribute(value, attr, ctx, lineno, col_offset, arena);
slice_ty slice;
expr_context_ty ctx;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Subscript");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_slice)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_slice);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_slice);
- if (tmp == NULL) goto failed;
res = obj2ast_slice(tmp, &slice, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
- if (tmp == NULL) goto failed;
res = obj2ast_expr_context(tmp, &ctx, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
+ }
return 1;
}
*out = Subscript(value, slice, ctx, lineno, col_offset, arena);
expr_ty value;
expr_context_ty ctx;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Starred");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
- if (tmp == NULL) goto failed;
res = obj2ast_expr_context(tmp, &ctx, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
+ }
return 1;
}
*out = Starred(value, ctx, lineno, col_offset, arena);
identifier id;
expr_context_ty ctx;
- if (_PyObject_HasAttrId(obj, &PyId_id)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_id);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_id);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &id, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
- if (tmp == NULL) goto failed;
res = obj2ast_expr_context(tmp, &ctx, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
+ }
return 1;
}
*out = Name(id, ctx, lineno, col_offset, arena);
asdl_seq* elts;
expr_context_ty ctx;
- if (_PyObject_HasAttrId(obj, &PyId_elts)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_elts);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
- if (tmp == NULL) goto failed;
res = obj2ast_expr_context(tmp, &ctx, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
+ }
return 1;
}
*out = List(elts, ctx, lineno, col_offset, arena);
asdl_seq* elts;
expr_context_ty ctx;
- if (_PyObject_HasAttrId(obj, &PyId_elts)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_elts);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ctx)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_ctx);
- if (tmp == NULL) goto failed;
res = obj2ast_expr_context(tmp, &ctx, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
+ }
return 1;
}
*out = Tuple(elts, ctx, lineno, col_offset, arena);
expr_ty upper;
expr_ty step;
- if (exists_not_none(obj, &PyId_lower)) {
+ tmp = get_not_none(obj, &PyId_lower);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_lower);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &lower, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
lower = NULL;
}
- if (exists_not_none(obj, &PyId_upper)) {
+ tmp = get_not_none(obj, &PyId_upper);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_upper);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &upper, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
upper = NULL;
}
- if (exists_not_none(obj, &PyId_step)) {
+ tmp = get_not_none(obj, &PyId_step);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_step);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &step, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
step = NULL;
}
if (isinstance) {
asdl_seq* dims;
- if (_PyObject_HasAttrId(obj, &PyId_dims)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_dims);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice");
+ }
return 1;
}
*out = ExtSlice(dims, arena);
if (isinstance) {
expr_ty value;
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 Index");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index");
+ }
return 1;
}
*out = Index(value, arena);
asdl_seq* ifs;
int is_async;
- if (_PyObject_HasAttrId(obj, &PyId_target)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_target);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_target);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &target, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_iter)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_iter);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_iter);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &iter, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_ifs)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_ifs);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_is_async)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_is_async);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_is_async);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &is_async, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
+ }
return 1;
}
*out = comprehension(target, iter, ifs, is_async, arena);
*out = NULL;
return 0;
}
- if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &lineno, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &col_offset, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
+ }
return 1;
}
isinstance = PyObject_IsInstance(obj, (PyObject*)ExceptHandler_type);
identifier name;
asdl_seq* body;
- if (exists_not_none(obj, &PyId_type)) {
+ tmp = get_not_none(obj, &PyId_type);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_type);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &type, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
type = NULL;
}
- if (exists_not_none(obj, &PyId_name)) {
+ tmp = get_not_none(obj, &PyId_name);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_name);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &name, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
name = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_body)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_body);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
+ }
return 1;
}
*out = ExceptHandler(type, name, body, lineno, col_offset, arena);
arg_ty kwarg;
asdl_seq* defaults;
- if (_PyObject_HasAttrId(obj, &PyId_args)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_args);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_vararg)) {
+ tmp = get_not_none(obj, &PyId_vararg);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_vararg);
- if (tmp == NULL) goto failed;
res = obj2ast_arg(tmp, &vararg, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
vararg = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_kwonlyargs)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_kwonlyargs);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_kw_defaults)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_kw_defaults);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_kwarg)) {
+ tmp = get_not_none(obj, &PyId_kwarg);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_kwarg);
- if (tmp == NULL) goto failed;
res = obj2ast_arg(tmp, &kwarg, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
kwarg = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_defaults)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_defaults);
+ if (tmp != NULL) {
int res;
Py_ssize_t len;
Py_ssize_t i;
- 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;
}
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
+ }
return 1;
}
*out = arguments(args, vararg, kwonlyargs, kw_defaults, kwarg, defaults,
int lineno;
int col_offset;
- if (_PyObject_HasAttrId(obj, &PyId_arg)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_arg);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_arg);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &arg, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_annotation)) {
+ tmp = get_not_none(obj, &PyId_annotation);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_annotation);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &annotation, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
annotation = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_lineno)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_lineno);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &lineno, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
+ }
return 1;
}
- if (_PyObject_HasAttrId(obj, &PyId_col_offset)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_col_offset);
- if (tmp == NULL) goto failed;
res = obj2ast_int(tmp, &col_offset, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
+ }
return 1;
}
*out = arg(arg, annotation, lineno, col_offset, arena);
identifier arg;
expr_ty value;
- if (exists_not_none(obj, &PyId_arg)) {
+ tmp = get_not_none(obj, &PyId_arg);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_arg);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &arg, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
arg = NULL;
}
- if (_PyObject_HasAttrId(obj, &PyId_value)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_value);
+ if (tmp != NULL) {
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 keyword");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
+ }
return 1;
}
*out = keyword(arg, value, arena);
identifier name;
identifier asname;
- if (_PyObject_HasAttrId(obj, &PyId_name)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_name);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_name);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &name, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_asname)) {
+ tmp = get_not_none(obj, &PyId_asname);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_asname);
- if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &asname, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
asname = NULL;
}
expr_ty context_expr;
expr_ty optional_vars;
- if (_PyObject_HasAttrId(obj, &PyId_context_expr)) {
+ tmp = _PyObject_GetAttrId(obj, &PyId_context_expr);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_context_expr);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &context_expr, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
- PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
+ if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
+ }
return 1;
}
- if (exists_not_none(obj, &PyId_optional_vars)) {
+ tmp = get_not_none(obj, &PyId_optional_vars);
+ if (tmp != NULL) {
int res;
- tmp = _PyObject_GetAttrId(obj, &PyId_optional_vars);
- if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &optional_vars, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
+ } else if (PyErr_Occurred()) {
+ return 1;
} else {
optional_vars = NULL;
}