diff --git a/CHANGES.rst b/CHANGES.rst index eec3c2fcf71..4ece866f2d4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,12 @@ Changelog (Pillow) ================== +7.1.1 (2020-04-02) +------------------ + +- Fix regression seeking and telling PNGs #4512 #4514 + [hugovk, radarhere] + 7.1.0 (2020-04-01) ------------------ diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index b6da365309c..469d186e816 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -629,6 +629,14 @@ def test_exif_argument(self, tmp_path): with Image.open(test_file) as reloaded: assert reloaded.info["exif"] == b"Exif\x00\x00exifstring" + def test_tell(self): + with Image.open(TEST_PNG_FILE) as im: + assert im.tell() == 0 + + def test_seek(self): + with Image.open(TEST_PNG_FILE) as im: + im.seek(0) + @pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS") @skip_unless_feature("zlib") diff --git a/docs/releasenotes/7.1.1.rst b/docs/releasenotes/7.1.1.rst new file mode 100644 index 00000000000..4c33adf8e9a --- /dev/null +++ b/docs/releasenotes/7.1.1.rst @@ -0,0 +1,25 @@ +7.1.1 +----- + +Fix regression seeking PNG files +================================ + +This fixes a regression introduced in 7.1.0 when adding support for APNG files when calling +``seek`` and ``tell``: + +.. code-block:: python + + >>> from PIL import Image + >>> with Image.open("Tests/images/hopper.png") as im: + ... im.seek(0) + ... + Traceback (most recent call last): + File "", line 2, in + File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 739, in seek + if not self._seek_check(frame): + File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PIL/ImageFile.py", line 306, in _seek_check + return self.tell() != frame + File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PIL/PngImagePlugin.py", line 827, in tell + return self.__frame + AttributeError: 'PngImageFile' object has no attribute '_PngImageFile__frame' + >>> diff --git a/docs/releasenotes/index.rst b/docs/releasenotes/index.rst index 1838803ded3..7cdb5849448 100644 --- a/docs/releasenotes/index.rst +++ b/docs/releasenotes/index.rst @@ -6,6 +6,7 @@ Release Notes .. toctree:: :maxdepth: 2 + 7.1.1 7.1.0 7.0.0 6.2.2 diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 81a9e36af5e..0291df4b097 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -636,6 +636,7 @@ def _open(self): if self.fp.read(8) != _MAGIC: raise SyntaxError("not a PNG file") self.__fp = self.fp + self.__frame = 0 # # Parse headers up to the first IDAT or fDAT chunk diff --git a/src/PIL/_version.py b/src/PIL/_version.py index 1e1f1af9343..857b2726e56 100644 --- a/src/PIL/_version.py +++ b/src/PIL/_version.py @@ -1,2 +1,2 @@ # Master version for Pillow -__version__ = "7.1.0" +__version__ = "7.1.1"