bpo-41204: Fix compiler warning in ast_type_init() (GH-21307)

This commit is contained in:
Victor Stinner 2020-07-04 23:18:15 +02:00 committed by GitHub
parent b40e434386
commit 1f76453173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -688,13 +688,14 @@ ast_clear(AST_object *self)
static int static int
ast_type_init(PyObject *self, PyObject *args, PyObject *kw) ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
{ {
astmodulestate *state = get_global_ast_state();
if (state == NULL) {
return -1;
}
Py_ssize_t i, numfields = 0; Py_ssize_t i, numfields = 0;
int res = -1; int res = -1;
PyObject *key, *value, *fields; PyObject *key, *value, *fields;
astmodulestate *state = get_global_ast_state();
if (state == NULL) {
goto cleanup;
}
if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) { if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
goto cleanup; goto cleanup;
} }

9
Python/Python-ast.c generated
View File

@ -1140,13 +1140,14 @@ ast_clear(AST_object *self)
static int static int
ast_type_init(PyObject *self, PyObject *args, PyObject *kw) ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
{ {
astmodulestate *state = get_global_ast_state();
if (state == NULL) {
return -1;
}
Py_ssize_t i, numfields = 0; Py_ssize_t i, numfields = 0;
int res = -1; int res = -1;
PyObject *key, *value, *fields; PyObject *key, *value, *fields;
astmodulestate *state = get_global_ast_state();
if (state == NULL) {
goto cleanup;
}
if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) { if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
goto cleanup; goto cleanup;
} }