From: Victor Stinner Date: Tue, 16 Jul 2013 22:17:15 +0000 (+0200) Subject: Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError) X-Git-Tag: v3.4.0a1~178 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bdf630c4a7e01141b0253a19c6cfc05a2dfc4e1b;p=python Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError) --- diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 9f855283eb..fe8fccdf79 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); } """ diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 744e640bce..71420c5e1e 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -7188,7 +7188,8 @@ PyInit__ast(void) PyObject* PyAST_mod2obj(mod_ty t) { - init_types(); + if (!init_types()) + return NULL; return ast2obj_mod(t); } @@ -7202,7 +7203,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) @@ -7220,7 +7222,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); }