Commit c416c7cb authored by Kenrick Everett's avatar Kenrick Everett Committed by GitHub

Fix bytearray iteration in 0.29.x (#4108)

By explicitly setting the result type
parent a7d98eea
......@@ -2876,6 +2876,10 @@ class NextNode(AtomicExprNode):
iterator_type = self.iterator.infer_type(env)
if iterator_type.is_ptr or iterator_type.is_array:
return iterator_type.base_type
elif self.iterator.sequence.type is bytearray_type:
# This is a temporary work-around to fix bytearray iteration in 0.29.x
# It has been fixed properly in master, refer to ticket: 3473
return py_object_type
elif iterator_type.is_cpp_class:
item_type = env.lookup_operator_for_types(self.pos, "*", [iterator_type]).type.return_type
if item_type.is_reference:
......
# mode: run
# ticket: 3473
def test_bytearray_iteration(src):
"""
>>> src = b'123'
>>> test_bytearray_iteration(src)
49
50
51
"""
data = bytearray(src)
for elem in data:
print(elem)
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