Commit 198f254f authored by Vitja Makarov's avatar Vitja Makarov

Always try global scope on class scope lookup failure

parent 38945955
......@@ -1670,17 +1670,15 @@ class NameNode(AtomicExprNode):
self.result(),
namespace,
interned_cname))
if self.cf_maybe_null:
if not self.cf_is_null:
code.putln('if (unlikely(!%s)) {' % self.result())
code.putln('PyErr_Clear();')
code.putln(
'%s = __Pyx_GetName(%s, %s);' % (
code.putln('if (unlikely(!%s)) {' % self.result())
code.putln('PyErr_Clear();')
code.putln(
'%s = __Pyx_GetName(%s, %s);' % (
self.result(),
Naming.module_cname,
interned_cname))
if not self.cf_is_null:
code.putln("}");
if not self.cf_is_null:
code.putln("}");
code.putln(code.error_goto_if_null(self.result(), self.pos))
code.put_gotref(self.py_result())
......
......@@ -78,3 +78,25 @@ def name_error_deleted():
"""
class X(object):
C = C
_set = set
def name_lookup_order():
"""
>>> Scope = name_lookup_order()
>>> Scope().set(2)
42
>>> Scope.test1 == _set()
True
>>> Scope.test2 == _set()
True
"""
class Scope(object):
test1 = set()
test2 = set()
def set(self, x):
return 42
return Scope
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment