Merge pull request #4942 from radarhere/del

Fixed bug in Exif __delitem__
This commit is contained in:
Hugo van Kemenade 2020-10-05 10:15:01 +03:00 committed by GitHub
commit 68c6740343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -650,12 +650,14 @@ class TestImage:
with Image.open("Tests/images/exif-72dpi-int.jpg") as im: # Little endian with Image.open("Tests/images/exif-72dpi-int.jpg") as im: # Little endian
exif = im.getexif() exif = im.getexif()
assert 258 not in exif assert 258 not in exif
assert 274 in exif
assert 40960 in exif assert 40960 in exif
assert exif[40963] == 450 assert exif[40963] == 450
assert exif[11] == "gThumb 3.0.1" assert exif[11] == "gThumb 3.0.1"
out = str(tmp_path / "temp.jpg") out = str(tmp_path / "temp.jpg")
exif[258] = 8 exif[258] = 8
del exif[274]
del exif[40960] del exif[40960]
exif[40963] = 455 exif[40963] = 455
exif[11] = "Pillow test" exif[11] = "Pillow test"
@ -663,6 +665,7 @@ class TestImage:
with Image.open(out) as reloaded: with Image.open(out) as reloaded:
reloaded_exif = reloaded.getexif() reloaded_exif = reloaded.getexif()
assert reloaded_exif[258] == 8 assert reloaded_exif[258] == 8
assert 274 not in reloaded_exif
assert 40960 not in reloaded_exif assert 40960 not in reloaded_exif
assert reloaded_exif[40963] == 455 assert reloaded_exif[40963] == 455
assert reloaded_exif[11] == "Pillow test" assert reloaded_exif[11] == "Pillow test"

View File

@ -3466,7 +3466,8 @@ class Exif(MutableMapping):
def __delitem__(self, tag): def __delitem__(self, tag):
if self._info is not None and tag in self._info: if self._info is not None and tag in self._info:
del self._info[tag] del self._info[tag]
del self._data[tag] else:
del self._data[tag]
def __iter__(self): def __iter__(self):
keys = set(self._data) keys = set(self._data)