Commit 6c486666 authored by Stefan Behnel's avatar Stefan Behnel

comments

parent 541d268c
...@@ -147,7 +147,7 @@ class IterationTransform(Visitor.VisitorTransform): ...@@ -147,7 +147,7 @@ class IterationTransform(Visitor.VisitorTransform):
if iterator.type is Builtin.dict_type: if iterator.type is Builtin.dict_type:
# like iterating over dict.keys() # like iterating over dict.keys()
if reversed: if reversed:
# (reversed) dict iteration uses arbitrary order # CPython raises an error here: not a sequence
return node return node
return self._transform_dict_iteration( return self._transform_dict_iteration(
node, dict_obj=iterator, keys=True, values=False) node, dict_obj=iterator, keys=True, values=False)
...@@ -167,7 +167,7 @@ class IterationTransform(Visitor.VisitorTransform): ...@@ -167,7 +167,7 @@ class IterationTransform(Visitor.VisitorTransform):
if isinstance(function, ExprNodes.AttributeNode) and \ if isinstance(function, ExprNodes.AttributeNode) and \
function.obj.type == Builtin.dict_type: function.obj.type == Builtin.dict_type:
if reversed: if reversed:
# (reversed) dict iteration uses arbitrary order # CPython raises an error here: not a sequence
return node return node
dict_obj = function.obj dict_obj = function.obj
method = function.attribute method = function.attribute
...@@ -190,13 +190,12 @@ class IterationTransform(Visitor.VisitorTransform): ...@@ -190,13 +190,12 @@ class IterationTransform(Visitor.VisitorTransform):
function.entry and function.entry.is_builtin: function.entry and function.entry.is_builtin:
if function.name == 'enumerate': if function.name == 'enumerate':
if reversed: if reversed:
# TODO: implement # CPython raises an error here: not a sequence
return node return node
return self._transform_enumerate_iteration(node, iterator) return self._transform_enumerate_iteration(node, iterator)
elif function.name == 'reversed': elif function.name == 'reversed':
if reversed: if reversed:
# it is not safe to short-cut here due to evaluation rules, # CPython raises an error here: not a sequence
# but this case is unlikely enough to just ignore it
return node return node
return self._transform_reversed_iteration(node, iterator) return self._transform_reversed_iteration(node, iterator)
......
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