Commit ff75036d authored by Stefan Behnel's avatar Stefan Behnel

cleanup

parent da68bab8
...@@ -52,24 +52,23 @@ class MarkAssignments(CythonTransform): ...@@ -52,24 +52,23 @@ class MarkAssignments(CythonTransform):
def visit_ForInStatNode(self, node): def visit_ForInStatNode(self, node):
# TODO: Remove redundancy with range optimization... # TODO: Remove redundancy with range optimization...
is_range = False is_special = False
sequence = node.iterator.sequence sequence = node.iterator.sequence
if isinstance(sequence, ExprNodes.SimpleCallNode): if isinstance(sequence, ExprNodes.SimpleCallNode):
function = sequence.function function = sequence.function
if sequence.self is None and \ if sequence.self is None and function.is_name:
isinstance(function, ExprNodes.NameNode) and \ if function.name in ('range', 'xrange'):
function.name in ('range', 'xrange'): is_special = True
is_range = True for arg in sequence.args[:2]:
self.mark_assignment(node.target, sequence.args[0]) self.mark_assignment(node.target, arg)
if len(sequence.args) > 1:
self.mark_assignment(node.target, sequence.args[1])
if len(sequence.args) > 2: if len(sequence.args) > 2:
self.mark_assignment(node.target, self.mark_assignment(
ExprNodes.binop_node(node.pos, node.target,
'+', ExprNodes.binop_node(node.pos,
sequence.args[0], '+',
sequence.args[2])) sequence.args[0],
if not is_range: sequence.args[2]))
if not is_special:
self.mark_assignment(node.target, object_expr) self.mark_assignment(node.target, object_expr)
self.visitchildren(node) self.visitchildren(node)
return node return node
...@@ -166,7 +165,7 @@ class SimpleAssignmentTypeInferer: ...@@ -166,7 +165,7 @@ class SimpleAssignmentTypeInferer:
if types: if types:
result_type = reduce(spanning_type, types) result_type = reduce(spanning_type, types)
else: else:
# List comprehension? # FIXME: raise a warning?
# print "No assignments", entry.pos, entry # print "No assignments", entry.pos, entry
result_type = py_object_type result_type = py_object_type
entry.type = find_safe_type(result_type, which_types_to_infer) entry.type = find_safe_type(result_type, which_types_to_infer)
......
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