Skip to content

Commit 075fb6f

Browse files
committed
CircuitPython 7 no longer allows StopIteration fallback
Now we have to explicitly catch it.
1 parent 071d6e8 commit 075fb6f

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

adafruit_imageload/gif.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,20 @@ def lzw_decode(data, code_size):
137137
"""Decode LZW-compressed data."""
138138
dictionary = LZWDict(code_size)
139139
bit = 0
140-
byte = next(data) # pylint: disable=stop-iteration-return
141140
try:
142-
while True:
143-
code = 0
144-
for i in range(dictionary.code_len):
145-
code |= ((byte >> bit) & 0x01) << i
146-
bit += 1
147-
if bit >= 8:
148-
bit = 0
149-
byte = next(data) # pylint: disable=stop-iteration-return
150-
yield dictionary.decode(code)
151-
except EndOfData:
152-
while True:
153-
next(data) # pylint: disable=stop-iteration-return
141+
byte = next(data)
142+
try:
143+
while True:
144+
code = 0
145+
for i in range(dictionary.code_len):
146+
code |= ((byte >> bit) & 0x01) << i
147+
bit += 1
148+
if bit >= 8:
149+
bit = 0
150+
byte = next(data)
151+
yield dictionary.decode(code)
152+
except EndOfData:
153+
while True:
154+
next(data)
155+
except StopIteration:
156+
pass

0 commit comments

Comments
 (0)