]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38425: Fix ‘res’ may be used uninitialized warning (GH-16688)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 10 Oct 2019 08:00:41 +0000 (01:00 -0700)
committerGitHub <noreply@github.com>
Thu, 10 Oct 2019 08:00:41 +0000 (01:00 -0700)
(cherry picked from commit a05fcd3c7adf6e3a0944da8cf80a3346882e9b3b)

Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Parser/asdl_c.py
Python/Python-ast.c

index 44e3d40c61553926a44436988479c387618579d1..20a71866e35773755f5361c9d851d27bc8bc3b03 100644 (file)
@@ -1209,7 +1209,6 @@ PyObject* PyAST_mod2obj(mod_ty t)
 /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
 {
-    mod_ty res;
     PyObject *req_type[3];
     char *req_name[] = {"Module", "Expression", "Interactive"};
     int isinstance;
@@ -1231,6 +1230,8 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
                      req_name[mode], Py_TYPE(ast)->tp_name);
         return NULL;
     }
+
+    mod_ty res = NULL;
     if (obj2ast_mod(ast, &res, arena) != 0)
         return NULL;
     else
index 6a2f28e0e712d52c3aed471202e5a21dec539e95..74fae33e5f4e65a972b92050d05e6037245c15c6 100644 (file)
@@ -8365,7 +8365,6 @@ PyObject* PyAST_mod2obj(mod_ty t)
 /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
 mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
 {
-    mod_ty res;
     PyObject *req_type[3];
     char *req_name[] = {"Module", "Expression", "Interactive"};
     int isinstance;
@@ -8387,6 +8386,8 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
                      req_name[mode], Py_TYPE(ast)->tp_name);
         return NULL;
     }
+
+    mod_ty res = NULL;
     if (obj2ast_mod(ast, &res, arena) != 0)
         return NULL;
     else