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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PIL/BlpImagePlugin.py
Expand Up @@ -306,7 +306,7 @@ def decode(self, buffer):
self._load()
except struct.error as e:
raise OSError("Truncated BLP file") from e
return 0, 0
return -1, 0

def _read_blp_header(self):
self.fd.seek(4)
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/ImageFile.py
Expand Up @@ -231,7 +231,7 @@ def load(self):
decoder.setimage(self.im, extents)
if decoder.pulls_fd:
decoder.setfd(self.fp)
status, err_code = decoder.decode(b"")
err_code = decoder.decode(b"")[1]
else:
b = prefix
while True:
Expand Down Expand Up @@ -664,7 +664,7 @@ def decode(self, buffer):

:param buffer: A bytes object with the data to be decoded.
:returns: A tuple of ``(bytes consumed, errcode)``.
If finished with decoding return 0 for the bytes consumed.
If finished with decoding return -1 for the bytes consumed.
Err codes are from :data:`.ImageFile.ERRORS`.
"""
raise NotImplementedError()
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/MspImagePlugin.py
Expand Up @@ -148,7 +148,7 @@ def decode(self, buffer):

self.set_as_raw(img.getvalue(), ("1", 0, 1))

return 0, 0
return -1, 0


Image.register_decoder("MSP", MspDecoder)
Expand Down