Skip to content

Fix KeyError on missing Interop or MakerNote IFD - #10177

Merged
radarhere merged 2 commits into
python-pillow:mainfrom
RavSinghChandan:exif-get-ifd-missing-interop
Oct 11, 2026
Merged

radarhere merged 2 commits into
python-pillow:mainfrom
RavSinghChandan:exif-get-ifd-missing-interop

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

Changes proposed in this pull request:

  • exif.get_ifd(ExifTags.IFD.Interop) and get_ifd(ExifTags.IFD.MakerNote) raised KeyError when the image has no Exif IFD, or an Exif IFD without that entry, which is most images (151 of the test images). A missing Exif, GPSInfo or IFD1 IFD already returns {} through the setdefault at the end of get_ifd(), as does a truncated MakerNote.
  • The entry is now looked up with .get(), and parsing is skipped when it is absent, so these return {} too.
  • Added a test for both IFDs, with no Exif IFD and with one that does not reference them.

@radarhere

Copy link
Copy Markdown
Member

Are you using AI to create these PRs?

@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Yes. I use Claude Code to help find bugs and draft the fixes, then I review every change myself, check that the new test fails without the fix, and run the full test suite locally before opening a PR. Happy to adjust anything, or close any you'd rather not take.

@radarhere radarhere added the 🤖-assisted AI-assisted label Oct 11, 2026
@radarhere radarhere changed the title Return an empty dict for a missing Interop or MakerNote IFD Fix KeyError on missing Interop or MakerNote IFD Oct 11, 2026
@radarhere
radarhere force-pushed the exif-get-ifd-missing-interop branch from 2e9ecff to 38ef547 Compare October 11, 2026 11:59
@radarhere
radarhere enabled auto-merge (squash) October 11, 2026 12:00
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Thanks for tidying it up!

@radarhere
radarhere merged commit 713aef8 into python-pillow:main Oct 11, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants