diff Python/Python-ast.c @ 84679:cf8f42eadbd0

Issue #18408: Fix Python-ast.c: handle init_types() failure (ex: MemoryError)
author Victor Stinner <victor.stinner@gmail.com>
date Wed, 17 Jul 2013 00:17:15 +0200
parents 12cbb5183d98
children 1b464f8453a4
line wrap: on
line diff
--- a/Python/Python-ast.c	Wed Jul 17 00:13:52 2013 +0200
+++ b/Python/Python-ast.c	Wed Jul 17 00:17:15 2013 +0200
@@ -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);
 }