summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-16 22:17:15 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-16 22:17:15 (GMT)
commitbdf630c4a7e01141b0253a19c6cfc05a2dfc4e1b (patch)
treef946e854f2e8ce5e3ade4a0f12e13d029308ca2f /Parser
parent6684bdf73dfb53d666ce9609cb4ecad3f020d006 (diff)
downloadcpython-bdf630c4a7e01141b0253a19c6cfc05a2dfc4e1b.zip
cpython-bdf630c4a7e01141b0253a19c6cfc05a2dfc4e1b.tar.gz
cpython-bdf630c4a7e01141b0253a19c6cfc05a2dfc4e1b.tar.bz2
Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
Diffstat (limited to 'Parser')
-rwxr-xr-xParser/asdl_c.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 9f85528..fe8fccd 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1191,7 +1191,8 @@ class PartingShots(StaticVisitor):
CODE = """
PyObject* PyAST_mod2obj(mod_ty t)
{
- init_types();
+ if (!init_types())
+ return NULL;
return ast2obj_mod(t);
}
@@ -1205,7 +1206,8 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
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 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
int PyAST_Check(PyObject* obj)
{
- init_types();
+ if (!init_types())
+ return -1;
return PyObject_IsInstance(obj, (PyObject*)&AST_type);
}
"""