[Python-checkins] bpo-41204: Fix compiler warning in ast_type_init() (GH-21307)

Victor Stinner webhook-mailer at python.org
Sat Jul 4 17:18:23 EDT 2020


https://github.com/python/cpython/commit/1f76453173267887ed05bb3783e862cb22365ae8
commit: 1f76453173267887ed05bb3783e862cb22365ae8
branch: master
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-07-04T23:18:15+02:00
summary:

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

files:
M Parser/asdl_c.py
M Python/Python-ast.c

diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index b93906ba8d45d..6fe44b99f793b 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -688,13 +688,14 @@ def visitModule(self, mod):
 static int
 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
 {
-    Py_ssize_t i, numfields = 0;
-    int res = -1;
-    PyObject *key, *value, *fields;
     astmodulestate *state = get_global_ast_state();
     if (state == NULL) {
-        goto cleanup;
+        return -1;
     }
+
+    Py_ssize_t i, numfields = 0;
+    int res = -1;
+    PyObject *key, *value, *fields;
     if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
         goto cleanup;
     }
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index b81b282a03965..396a6832702b3 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -1140,13 +1140,14 @@ ast_clear(AST_object *self)
 static int
 ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
 {
-    Py_ssize_t i, numfields = 0;
-    int res = -1;
-    PyObject *key, *value, *fields;
     astmodulestate *state = get_global_ast_state();
     if (state == NULL) {
-        goto cleanup;
+        return -1;
     }
+
+    Py_ssize_t i, numfields = 0;
+    int res = -1;
+    PyObject *key, *value, *fields;
     if (_PyObject_LookupAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
         goto cleanup;
     }



More information about the Python-checkins mailing list