work-around for ticket #691: look up unknown global names in builtins at runtime
authorStefan Behnel <scoder@users.berlios.de>
Wed, 27 Apr 2011 13:40:41 +0000 (15:40 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Wed, 27 Apr 2011 13:40:41 +0000 (15:40 +0200)
Cython/Compiler/ExprNodes.py

index 496aa461f1823da1932dcf43c974d30463856f94..7fc9f6ddb26e05b62afd9e8d2e6988f31f30b49e 100755 (executable)
@@ -7691,11 +7691,18 @@ impl = """
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
     PyObject *result;
     result = PyObject_GetAttr(dict, name);
-    if (!result)
-        PyErr_SetObject(PyExc_NameError, name);
+    if (!result) {
+        if (dict != %(BUILTINS)s) {
+            PyErr_Clear();
+            result = PyObject_GetAttr(%(BUILTINS)s, name);
+        }
+        if (!result) {
+            PyErr_SetObject(PyExc_NameError, name);
+        }
+    }
     return result;
 }
-""")
+""" % {'BUILTINS' : Naming.builtins_cname})
 
 #------------------------------------------------------------------------------------