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
2f877a77
Commit
2f877a77
authored
Nov 25, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ticket #598: list comprehensions in closures
parent
23f8f11f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+6
-6
tests/bugs.txt
tests/bugs.txt
+0
-1
No files found.
Cython/Compiler/Symtab.py
View file @
2f877a77
...
...
@@ -1287,19 +1287,19 @@ class LocalScope(Scope):
entry.original_cname = entry.cname
entry.cname = "%s->%s" % (Naming.cur_scope_cname, entry.cname)
class GeneratorExpressionScope(
Local
Scope):
class GeneratorExpressionScope(Scope):
"""Scope for generator expressions and comprehensions. As opposed
to generators, these can be easily inlined in some cases, so all
we really need is a scope that holds the loop variable(s).
"""
def __init__(self, outer_scope):
name = outer_scope.global_scope().next_id(Naming.genexpr_id_ref)
LocalScope.__init__(self, nam
e, outer_scope)
Scope.__init__(self, name, outer_scop
e, outer_scope)
self.directives = outer_scope.directives
self.genexp_prefix = "%s%d%s" % (Naming.pyrex_prefix, len(name), name)
def mangle(self, prefix, name):
return '
%
s
%
s
' % (self.genexp_prefix, self.
outer
_scope.mangle(self, prefix, name))
return '
%
s
%
s
' % (self.genexp_prefix, self.
parent
_scope.mangle(self, prefix, name))
def declare_var(self, name, type, pos,
cname = None, visibility = '
private
', is_cdef = True):
...
...
@@ -1308,10 +1308,10 @@ class GeneratorExpressionScope(LocalScope):
outer_entry = self.outer_scope.lookup(name)
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
# the
parent
scope needs to generate code for the variable, but
# this scope must hold its name exclusively
cname = '
%
s
%
s
' % (self.genexp_prefix, self.
outer
_scope.mangle(Naming.var_prefix, name))
entry = self.
outer
_scope.declare_var(None, type, pos, cname, visibility, is_cdef = True)
cname = '
%
s
%
s
' % (self.genexp_prefix, self.
parent
_scope.mangle(Naming.var_prefix, name))
entry = self.
parent
_scope.declare_var(None, type, pos, cname, visibility, is_cdef = True)
self.entries[name] = entry
return entry
...
...
tests/bugs.txt
View file @
2f877a77
...
...
@@ -17,7 +17,6 @@ function_as_method_T494
closure_inside_cdef_T554
ipow_crash_T562
pure_mode_cmethod_inheritance_T583
list_comp_in_closure_T598
genexpr_iterable_lookup_T600
# CPython regression tests that don't current work:
...
...
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