Commit 9185e2ca authored by Stefan Behnel's avatar Stefan Behnel

fix declaration of Python classes with names that shadow builtins

parent 239de7a4
...@@ -1997,13 +1997,12 @@ class AlignFunctionDefinitions(CythonTransform): ...@@ -1997,13 +1997,12 @@ class AlignFunctionDefinitions(CythonTransform):
if pxd_def: if pxd_def:
if pxd_def.is_cclass: if pxd_def.is_cclass:
return self.visit_CClassDefNode(node.as_cclass(), pxd_def) return self.visit_CClassDefNode(node.as_cclass(), pxd_def)
else: elif not pxd_def.scope or not pxd_def.scope.is_builtin_scope:
error(node.pos, "'%s' redeclared" % node.name) error(node.pos, "'%s' redeclared" % node.name)
if pxd_def.pos: if pxd_def.pos:
error(pxd_def.pos, "previous declaration here") error(pxd_def.pos, "previous declaration here")
return None return None
else: return node
return node
def visit_CClassDefNode(self, node, pxd_def=None): def visit_CClassDefNode(self, node, pxd_def=None):
if pxd_def is None: if pxd_def is None:
......
class set(object):
def __init__(self, x):
self.x = x
SET = set([1])
class set(object):
def __init__(self, x):
self.X = x
def test_class_redef(x):
"""
>>> SET.x
[1]
>>> test_class_redef(2).X
[2]
"""
return set([x])
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