Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode() should return -1 when finished #6117

Merged
merged 2 commits into from Mar 10, 2022
Merged

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.

None yet

2 participants