Commit ae62e5ee authored by Stefan Behnel's avatar Stefan Behnel

enable previously unused optimisation code for bytes iteration (found via coverage analysis)

parent 33af5045
......@@ -237,7 +237,7 @@ class IterationTransform(Visitor.VisitorTransform):
def _transform_bytes_iteration(self, node, slice_node, reversed=False):
target_type = node.target.type
if not target_type.is_int:
if not target_type.is_int and target_type is not Builtin.bytes_type:
# bytes iteration returns bytes objects in Py2, but
# integers in Py3
return node
......
......@@ -46,6 +46,21 @@ def slice_charptr_for_loop_c():
print [ chr(c) for c in cstring[1:5] ]
print [ chr(c) for c in cstring[4:9] ]
#@cython.test_assert_path_exists("//ForFromStatNode",
# "//ForFromStatNode//IndexNode")
#@cython.test_fail_if_path_exists("//ForInStatNode")
def slice_charptr_for_loop_c_to_bytes():
"""
>>> slice_charptr_for_loop_c_to_bytes()
['a', 'b', 'c']
['b', 'c', 'A', 'B']
['B', 'C', 'q', 't', 'p']
"""
cdef bytes b
print [ b for b in cstring[:3] ]
print [ b for b in cstring[1:5] ]
print [ b for b in cstring[4:9] ]
@cython.test_assert_path_exists("//ForFromStatNode",
"//ForFromStatNode//IndexNode")
@cython.test_fail_if_path_exists("//ForInStatNode")
......
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