Compare commits

...

14 Commits
main ... 7.1.x

Author SHA1 Message Date
Hugo
4f6145655b 7.1.2 version bump 2020-04-25 08:47:14 +03:00
Hugo
f6358a68f0 Release notes for 7.1.2 2020-04-25 08:46:40 +03:00
Andrew Murray
e038c84ca9 Update pip to fix pyqt5 install 2020-04-24 22:49:44 +03:00
Andrew Murray
1f3ccd1298 Fixed error making HTML from docs 2020-04-24 22:30:40 +03:00
Andrew Murray
ab1835df5c Assert that seeking too far raises an EOFError 2020-04-24 22:30:35 +03:00
Andrew Murray
92adfaad2b Replaced property methods for n_frames and is_animated with normal properties 2020-04-24 22:30:29 +03:00
Hugo
ed40d04ac4 Add 7.1.1 release notes to index 2020-04-02 15:41:33 +03:00
Hugo
c56579bb0c 7.1.1 version bump 2020-04-02 15:11:01 +03:00
Hugo van Kemenade
8343d5a7bf Fix typo
[CI skip]

Co-Authored-By: Andrew Murray <3112309+radarhere@users.noreply.github.com>
2020-04-02 15:03:06 +03:00
Hugo
5bccd32bbd Release notes for 7.1.1 [CI skip] 2020-04-02 15:03:02 +03:00
Andrew Murray
bf5a69acad Removed redundant arguments 2020-04-02 15:02:57 +03:00
Hugo
f6d90cef12 Initialise __frame = 0 in open, and test tell 2020-04-02 15:02:52 +03:00
Hugo
e0b8cebf6e Add test case 2020-04-02 15:02:47 +03:00
Hugo
ca85b0da24 Initialise __frame = 0 2020-04-02 15:02:43 +03:00
9 changed files with 75 additions and 16 deletions

View File

@ -7,6 +7,7 @@ sudo apt-get -qq install libfreetype6-dev liblcms2-dev python3-tk\
ghostscript libffi-dev libjpeg-turbo-progs libopenjp2-7-dev\
cmake imagemagick libharfbuzz-dev libfribidi-dev
pip install --upgrade pip
PYTHONOPTIMIZE=0 pip install cffi
pip install coverage
pip install olefile
@ -20,7 +21,7 @@ if [[ $TRAVIS_PYTHON_VERSION == 3.* ]]; then
# "ERROR: Could not find a version that satisfies the requirement pyqt5"
if [[ $TRAVIS_CPU_ARCH == "amd64" ]]; then
sudo apt-get -qq install pyqt5-dev-tools
pip install pyqt5!=5.14.1
pip install pyqt5
fi
fi

View File

@ -2,6 +2,18 @@
Changelog (Pillow)
==================
7.1.2 (2020-04-25)
------------------
- Raise an EOFError when seeking too far in PNG #4528
[radarhere]
7.1.1 (2020-04-02)
------------------
- Fix regression seeking and telling PNGs #4512 #4514
[hugovk, radarhere]
7.1.0 (2020-04-01)
------------------

View File

@ -629,6 +629,17 @@ class TestFilePng:
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)
with pytest.raises(EOFError):
im.seek(1)
@pytest.mark.skipif(is_win32(), reason="Requires Unix or macOS")
@skip_unless_feature("zlib")

View File

@ -229,7 +229,7 @@ Plugin reference
----------------------------
.. automodule:: PIL.PngImagePlugin
:members: ChunkStream, PngImageFile, PngStream, getchunks, is_cid, putchunk
:members: ChunkStream, PngStream, getchunks, is_cid, putchunk
:show-inheritance:
.. autoclass:: PIL.PngImagePlugin.ChunkStream
:members:

View File

@ -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 "<stdin>", line 2, in <module>
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'
>>>

View File

@ -0,0 +1,16 @@
7.1.2
-----
Fix another regression seeking PNG files
========================================
This fixes a regression introduced in 7.1.0 when adding support for APNG files.
When calling ``seek(n)`` on a regular PNG where ``n > 0``, it failed to raise an
``EOFError`` as it should have done, resulting in:
.. code-block:: python
AttributeError: 'NoneType' object has no attribute 'read'
Pillow 7.1.2 now raises the correct exception.

View File

@ -6,6 +6,8 @@ Release Notes
.. toctree::
:maxdepth: 2
7.1.2
7.1.1
7.1.0
7.0.0
6.2.2

View File

@ -636,6 +636,7 @@ class PngImageFile(ImageFile.ImageFile):
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
@ -672,7 +673,7 @@ class PngImageFile(ImageFile.ImageFile):
self._text = None
self.tile = self.png.im_tile
self.custom_mimetype = self.png.im_custom_mimetype
self._n_frames = self.png.im_n_frames
self.n_frames = self.png.im_n_frames or 1
self.default_image = self.info.get("default_image", False)
if self.png.im_palette:
@ -684,15 +685,16 @@ class PngImageFile(ImageFile.ImageFile):
else:
self.__prepare_idat = length # used by load_prepare()
if self._n_frames is not None:
if self.png.im_n_frames is not None:
self._close_exclusive_fp_after_loading = False
self.png.save_rewind()
self.__rewind_idat = self.__prepare_idat
self.__rewind = self.__fp.tell()
if self.default_image:
# IDAT chunk contains default image and not first animation frame
self._n_frames += 1
self.n_frames += 1
self._seek(0)
self.is_animated = self.n_frames > 1
@property
def text(self):
@ -709,16 +711,6 @@ class PngImageFile(ImageFile.ImageFile):
self.seek(frame)
return self._text
@property
def n_frames(self):
if self._n_frames is None:
return 1
return self._n_frames
@property
def is_animated(self):
return self._n_frames is not None and self._n_frames > 1
def verify(self):
"""Verify PNG file"""

View File

@ -1,2 +1,2 @@
# Master version for Pillow
__version__ = "7.1.0"
__version__ = "7.1.2"