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
Gwenaël Samain
cython
Commits
fdd78468
Commit
fdd78468
authored
May 25, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support genexp loop variables that override builtin names or global functions etc.
parent
0948e79c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+1
-1
tests/run/any.pyx
tests/run/any.pyx
+35
-0
No files found.
Cython/Compiler/Symtab.py
View file @
fdd78468
...
...
@@ -1278,7 +1278,7 @@ class GeneratorExpressionScope(LocalScope):
if type is unspecified_type:
# if the outer scope defines a type for this variable, inherit it
outer_entry = self.outer_scope.lookup(name)
if outer_entry and
not outer_entry.is_builtin
:
if outer_entry and
outer_entry.is_variable
:
type = outer_entry.type # may still be '
unspecified_type
' !
# the outer scope needs to generate code for the variable, but
# this scope must hold its name exclusively
...
...
tests/run/any.pyx
View file @
fdd78468
...
...
@@ -51,6 +51,7 @@ def any_item(x):
"""
return
any
(
x
)
@
cython
.
test_assert_path_exists
(
"//ForInStatNode"
,
"//InlinedGeneratorExpressionNode"
)
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
,
...
...
@@ -78,6 +79,7 @@ def any_in_simple_gen(seq):
"""
return
any
(
x
for
x
in
seq
)
@
cython
.
test_assert_path_exists
(
"//ForInStatNode"
,
"//InlinedGeneratorExpressionNode"
)
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
,
...
...
@@ -108,6 +110,7 @@ def any_in_simple_gen_scope(seq):
assert
x
==
'abc'
return
result
@
cython
.
test_assert_path_exists
(
"//ForInStatNode"
,
"//InlinedGeneratorExpressionNode"
)
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
,
...
...
@@ -142,6 +145,7 @@ mixed_ustring = u'AbcDefGhIjKlmnoP'
lower_ustring
=
mixed_ustring
.
lower
()
upper_ustring
=
mixed_ustring
.
upper
()
@
cython
.
test_assert_path_exists
(
'//PythonCapiCallNode'
,
'//ForFromStatNode'
,
"//InlinedGeneratorExpressionNode"
)
...
...
@@ -158,6 +162,7 @@ def any_lower_case_characters(unicode ustring):
"""
return
any
(
uchar
.
islower
()
for
uchar
in
ustring
)
@
cython
.
test_assert_path_exists
(
"//ForInStatNode"
,
"//InlinedGeneratorExpressionNode"
,
"//InlinedGeneratorExpressionNode//IfStatNode"
)
...
...
@@ -188,6 +193,36 @@ def any_in_typed_gen(seq):
cdef
int
x
return
any
(
x
for
x
in
seq
)
@
cython
.
test_assert_path_exists
(
"//ForInStatNode"
,
"//InlinedGeneratorExpressionNode"
,
"//InlinedGeneratorExpressionNode//IfStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//SimpleCallNode"
,
"//YieldExprNode"
)
def
any_in_gen_builtin_name
(
seq
):
"""
>>> any_in_gen_builtin_name([0,1,0])
True
>>> any_in_gen_builtin_name([0,0,0])
False
>>> any_in_gen_builtin_name(VerboseGetItem([0,0,1,0,0]))
0
1
2
True
>>> any_in_gen_builtin_name(VerboseGetItem([0,0,0,0,0]))
0
1
2
3
4
5
False
"""
return
any
(
type
for
type
in
seq
)
@
cython
.
test_assert_path_exists
(
"//ForInStatNode"
,
"//InlinedGeneratorExpressionNode"
,
"//InlinedGeneratorExpressionNode//IfStatNode"
)
...
...
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