Skip to content

Comments

Fix self.decode typo#9445

Merged
hugovk merged 4 commits intopython-pillow:mainfrom
bysiber:fix-parser-decode-typo
Feb 21, 2026
Merged

Fix self.decode typo#9445
hugovk merged 4 commits intopython-pillow:mainfrom
bysiber:fix-parser-decode-typo

Conversation

@bysiber
Copy link
Contributor

@bysiber bysiber commented Feb 20, 2026

In ImageFile.Parser, the class uses self.decoder throughout (initialized on line 516, checked on line 545, set on line 590). But line 584 assigns self.decode = None (missing the trailing "r"), which creates a new attribute that's never referenced anywhere.

The intent is clearly to reset self.decoder to None when the image has custom load code or multiple tiles, so the parser falls through to the elif self.image: branch on subsequent feed() calls.

@radarhere radarhere mentioned this pull request Feb 20, 2026
@radarhere
Copy link
Member

I've created bysiber#1 with a suggestion to simplify the code.

@hugovk
Copy link
Member

hugovk commented Feb 20, 2026

Rather than:

if condition:
    pass
else:
    do_thing()

Invert and drop the else:

if not condition:
    do_thing()

(And rewrite the condition.)

As suggested by hugovk — replace 'if flag: pass; else: ...' with
the inverted 'if not flag: ...' for clarity.
@bysiber
Copy link
Contributor Author

bysiber commented Feb 20, 2026

Good call, inverted the condition so it reads more naturally. Pushed.

@hugovk hugovk changed the title Fix typo: self.decode -> self.decoder in Parser Fix self.decode typo Feb 21, 2026
@hugovk hugovk merged commit 43c12af into python-pillow:main Feb 21, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants