Merge pull request #8230 from radarhere/exif_get_ifd

This commit is contained in:
Hugo van Kemenade 2024-09-04 14:46:18 +03:00 committed by GitHub
commit e2c13571c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -775,6 +775,14 @@ class TestImage:
exif.load(b"Exif\x00\x00")
assert not dict(exif)
def test_empty_get_ifd(self) -> None:
exif = Image.Exif()
ifd = exif.get_ifd(0x8769)
assert ifd == {}
ifd[36864] = b"0220"
assert exif.get_ifd(0x8769) == {36864: b"0220"}
@mark_if_feature_version(
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
)

View File

@ -4136,7 +4136,7 @@ class Exif(_ExifBase):
ifd = self._get_ifd_dict(tag_data, tag)
if ifd is not None:
self._ifds[tag] = ifd
ifd = self._ifds.get(tag, {})
ifd = self._ifds.setdefault(tag, {})
if tag == ExifTags.IFD.Exif and self._hidden_data:
ifd = {
k: v