From: Stefan Behnel Date: Wed, 27 Apr 2011 13:40:41 +0000 (+0200) Subject: work-around for ticket #691: look up unknown global names in builtins at runtime X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c13cdca3dd49170b18de0fb79d7564acf0ad7bf1;p=cython.git work-around for ticket #691: look up unknown global names in builtins at runtime --- 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}) #------------------------------------------------------------------------------------