From ef16cb8efe6a9c12034d2343783b51beb0ff9ba5 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 7 Sep 2019 18:31:23 +1000 Subject: [PATCH] ImageFileDirectory_v1 does not raise KeyError --- src/PIL/Image.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 7c6a46fa7..b0ba266e0 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -3327,19 +3327,13 @@ class Exif(MutableMapping): return tag in self def __setitem__(self, tag, value): - if self._info is not None: - try: - del self._info[tag] - except KeyError: - pass + if self._info is not None and tag in self._info: + del self._info[tag] self._data[tag] = value def __delitem__(self, tag): - if self._info is not None: - try: - del self._info[tag] - except KeyError: - pass + if self._info is not None and tag in self._info: + del self._info[tag] del self._data[tag] def __iter__(self):