Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
9185e2ca
Commit
9185e2ca
authored
Aug 24, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix declaration of Python classes with names that shadow builtins
parent
239de7a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-3
tests/run/class_redefine.py
tests/run/class_redefine.py
+19
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
9185e2ca
...
@@ -1997,12 +1997,11 @@ class AlignFunctionDefinitions(CythonTransform):
...
@@ -1997,12 +1997,11 @@ 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
)
el
s
e
:
el
if
not
pxd_def
.
scope
or
not
pxd_def
.
scope
.
is_builtin_scop
e
:
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
):
...
...
tests/run/class_redefine.py
0 → 100644
View file @
9185e2ca
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
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment