Skip to content

Remove unused cleanup return value - #10101

Merged
hugovk merged 2 commits into
python-pillow:mainfrom
radarhere:encode_cleanup
Oct 2, 2026
Merged

hugovk merged 2 commits into
python-pillow:mainfrom
radarhere:encode_cleanup

Conversation

@radarhere

@radarhere radarhere commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

The return values from C's cleanup() methods

Pillow/src/decode.c

Lines 143 to 150 in d01e2fe

_decode_cleanup(ImagingDecoderObject *decoder, PyObject *args) {
int status = 0;
if (decoder->cleanup) {
status = decoder->cleanup(&decoder->state);
}
return Py_BuildValue("i", status);

Pillow/src/encode.c

Lines 110 to 117 in d01e2fe

_encode_cleanup(ImagingEncoderObject *encoder, PyObject *args) {
int status = 0;
if (encoder->cleanup) {
status = encoder->cleanup(&encoder->state);
}
return Py_BuildValue("i", status);

aren't used in Python.

decoder.cleanup()

encoder.cleanup()

@akx akx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a small note about zlib, but it's fine (it's been unchecked forever anyway).


/* Clean up */
if (context->previous) {
inflateEnd(&context->z_stream);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the docs, inflateEnd is fallible, but the conditions in which it would fail seem rare enough that it's not worth it to check here:

On error, inflateEnd() shall return Z_STREAM_ERROR. The following conditions shall be treated as an error:

  • The state in stream is inconsistent.
  • stream is NULL.
  • The zfree function pointer is NULL.

So this is fine 👍

@hugovk
hugovk merged commit 0be6bed into python-pillow:main Oct 2, 2026
60 checks passed
@radarhere
radarhere deleted the encode_cleanup branch October 2, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants