From c13cdca3dd49170b18de0fb79d7564acf0ad7bf1 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 27 Apr 2011 15:40:41 +0200 Subject: [PATCH] work-around for ticket #691: look up unknown global names in builtins at runtime --- Cython/Compiler/ExprNodes.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 496aa461..7fc9f6dd 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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}) #------------------------------------------------------------------------------------ -- 2.26.2