[Python-checkins] cpython: Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
victor.stinner
python-checkins at python.org
Wed Jul 17 01:01:24 CEST 2013
http://hg.python.org/cpython/rev/cf8f42eadbd0
changeset: 84679:cf8f42eadbd0
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Jul 17 00:17:15 2013 +0200
summary:
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
files:
Parser/asdl_c.py | 9 ++++++---
Python/Python-ast.c | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1191,7 +1191,8 @@
CODE = """
PyObject* PyAST_mod2obj(mod_ty t)
{
- init_types();
+ if (!init_types())
+ return NULL;
return ast2obj_mod(t);
}
@@ -1205,7 +1206,8 @@
int isinstance;
assert(0 <= mode && mode <= 2);
- init_types();
+ if (!init_types())
+ return NULL;
isinstance = PyObject_IsInstance(ast, req_type[mode]);
if (isinstance == -1)
@@ -1223,7 +1225,8 @@
int PyAST_Check(PyObject* obj)
{
- init_types();
+ if (!init_types())
+ return -1;
return PyObject_IsInstance(obj, (PyObject*)&AST_type);
}
"""
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -7188,7 +7188,8 @@
PyObject* PyAST_mod2obj(mod_ty t)
{
- init_types();
+ if (!init_types())
+ return NULL;
return ast2obj_mod(t);
}
@@ -7202,7 +7203,8 @@
int isinstance;
assert(0 <= mode && mode <= 2);
- init_types();
+ if (!init_types())
+ return NULL;
isinstance = PyObject_IsInstance(ast, req_type[mode]);
if (isinstance == -1)
@@ -7220,7 +7222,8 @@
int PyAST_Check(PyObject* obj)
{
- init_types();
+ if (!init_types())
+ return -1;
return PyObject_IsInstance(obj, (PyObject*)&AST_type);
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list