Skip to content

Conversation

@radarhere
Copy link
Member

I made a mistake in #6069, when I wrote that for PyDecoder, when decode() is finished, it should "return 0 for the bytes consumed." It should be a negative number instead.

This can be seen from the ImageFile code

Pillow/src/PIL/ImageFile.py

Lines 257 to 259 in 397a940

n, err_code = decoder.decode(b)
if n < 0:
break

and also from Tests/test_imagefile.py
class MockPyDecoder(ImageFile.PyDecoder):
def decode(self, buffer):
# eof
return -1, 0

which causes the test suite to fail if the return value is changed to 0, 0 instead.

@hugovk hugovk merged commit 5c931de into python-pillow:main Mar 10, 2022
@radarhere radarhere deleted the return branch March 10, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants