[Python-checkins] bpo-38425: Fix ‘res’ may be used uninitialized warning (GH-16688)
Miss Islington (bot)
webhook-mailer at python.org
Thu Oct 10 04:00:45 EDT 2019
https://github.com/python/cpython/commit/d27a9b1695a1b46c81b3a83a7a35034791265d89
commit: d27a9b1695a1b46c81b3a83a7a35034791265d89
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-10-10T01:00:41-07:00
summary:
bpo-38425: Fix ‘res’ may be used uninitialized warning (GH-16688)
(cherry picked from commit a05fcd3c7adf6e3a0944da8cf80a3346882e9b3b)
Co-authored-by: Dong-hee Na <donghee.na92 at gmail.com>
files:
M Parser/asdl_c.py
M Python/Python-ast.c
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 44e3d40c61553..20a71866e3577 100644
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1209,7 +1209,6 @@ class PartingShots(StaticVisitor):
/* 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 @@ class PartingShots(StaticVisitor):
req_name[mode], Py_TYPE(ast)->tp_name);
return NULL;
}
+
+ mod_ty res = NULL;
if (obj2ast_mod(ast, &res, arena) != 0)
return NULL;
else
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 6a2f28e0e712d..74fae33e5f4e6 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -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
More information about the Python-checkins
mailing list