Skip to content

Commit

Permalink
Portable xrange/range detection across python version
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-sans-paille committed May 31, 2017
1 parent 51f717d commit 0f5f10c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pythran/backend.py
Expand Up @@ -881,11 +881,12 @@ def can_use_c_for(self, node):
- order have to be known at compile time
"""
assert isinstance(node.target, ast.Name)
pattern = ast.Call(func=ast.Attribute(value=ast.Name(id='__builtin__',
ctx=ast.Load(),
annotation=None),
attr='xrange', ctx=ast.Load()),
args=AST_any(), keywords=[])
pattern = ast.Call(func=ast.Attribute(
value=ast.Name(id='__builtin__',
ctx=ast.Load(),
annotation=None),
attr=xrange.__name__, ctx=ast.Load()),
args=AST_any(), keywords=[])
is_assigned = {node.target.id: False}
[is_assigned.update(self.passmanager.gather(IsAssigned, stmt))
for stmt in node.body]
Expand Down

0 comments on commit 0f5f10c

Please sign in to comment.