Skip to content

Commit db76eaa

Browse files
authored
Merge branch 'main' into comment_correct_placement
2 parents 6257e78 + 30a0e44 commit db76eaa

38 files changed

+290
-204
lines changed

.github/workflows/test-docker.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
matrix:
1212
docker: [
1313
# Run slower jobs first to give them a headstart and reduce waiting time
14-
ubuntu-20.04-focal-arm64v8,
15-
ubuntu-20.04-focal-ppc64le,
16-
ubuntu-20.04-focal-s390x,
14+
ubuntu-22.04-jammy-arm64v8,
15+
ubuntu-22.04-jammy-ppc64le,
16+
ubuntu-22.04-jammy-s390x,
1717
# Then run the remainder
1818
alpine,
1919
amazon-2-amd64,
@@ -32,11 +32,11 @@ jobs:
3232
]
3333
dockerTag: [main]
3434
include:
35-
- docker: "ubuntu-20.04-focal-arm64v8"
35+
- docker: "ubuntu-22.04-jammy-arm64v8"
3636
qemu-arch: "aarch64"
37-
- docker: "ubuntu-20.04-focal-ppc64le"
37+
- docker: "ubuntu-22.04-jammy-ppc64le"
3838
qemu-arch: "ppc64le"
39-
- docker: "ubuntu-20.04-focal-s390x"
39+
- docker: "ubuntu-22.04-jammy-s390x"
4040
qemu-arch: "s390x"
4141

4242
name: ${{ matrix.docker }}

CHANGES.rst

+27-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ Changelog (Pillow)
55
9.2.0 (unreleased)
66
------------------
77

8+
- Separate multiple GIF comment blocks with newlines #6294
9+
[raygard, radarhere]
10+
11+
- Always use GIF89a for comments #6292
12+
[raygard, radarhere]
13+
14+
- Ignore compression value from BMP info dictionary when saving as TIFF #6231
15+
[radarhere]
16+
17+
- If font is file-like object, do not re-read from object to get variant #6234
18+
[radarhere]
19+
20+
- Raise ValueError when trying to access internal fp after close #6213
21+
[radarhere]
22+
23+
- Support more affine expression forms in im.point() #6254
24+
[benrg, radarhere]
25+
826
- Populate Python palette in fromarray() #6283
927
[radarhere]
1028

@@ -17,9 +35,6 @@ Changelog (Pillow)
1735
- Adjust BITSPERSAMPLE to match SAMPLESPERPIXEL when opening TIFFs #6270
1836
[radarhere]
1937

20-
- Do not open images with zero or negative height #6269
21-
[radarhere]
22-
2338
- Search pkgconf system libs/cflags #6138
2439
[jameshilliard, radarhere]
2540

@@ -50,6 +65,15 @@ Changelog (Pillow)
5065
- Deprecated PhotoImage.paste() box parameter #6178
5166
[radarhere]
5267

68+
9.1.1 (2022-05-17)
69+
------------------
70+
71+
- When reading past the end of a TGA scan line, reduce bytes left. CVE-2022-30595
72+
[radarhere]
73+
74+
- Do not open images with zero or negative height #6269
75+
[radarhere]
76+
5377
9.1.0 (2022-04-01)
5478
------------------
5579

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ release-test:
8585
sdist:
8686
python3 -m build --help > /dev/null 2>&1 || python3 -m pip install build
8787
python3 -m build --sdist
88+
python3 -m twine --help > /dev/null 2>&1 || python3 -m pip install twine
89+
python3 -m twine check --strict dist/*
8890

8991
.PHONY: test
9092
test:

RELEASING.md

-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Released quarterly on January 2nd, April 1st, July 1st and October 15th.
2424
* [ ] Create and check source distribution:
2525
```bash
2626
make sdist
27-
python3 -m twine check --strict dist/*
2827
```
2928
* [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions)
3029
* [ ] Check and upload all binaries and source distributions e.g.:
@@ -61,7 +60,6 @@ Released as needed for security, installation or critical bug fixes.
6160
* [ ] Create and check source distribution:
6261
```bash
6362
make sdist
64-
python3 -m twine check --strict dist/*
6563
```
6664
* [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions)
6765
* [ ] Check and upload all binaries and source distributions e.g.:
@@ -91,7 +89,6 @@ Released as needed privately to individual vendors for critical security-related
9189
* [ ] Create and check source distribution:
9290
```bash
9391
make sdist
94-
python3 -m twine check --strict dist/*
9592
```
9693
* [ ] Create [binary distributions](https://github.com/python-pillow/Pillow/blob/main/RELEASING.md#binary-distributions)
9794
* [ ] Publish the [release on GitHub](https://github.com/python-pillow/Pillow/releases)
4.77 KB
Binary file not shown.

Tests/images/multiple_comments.gif

1.5 KB
Loading

Tests/test_file_apng.py

+9
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,15 @@ def test_apng_save_blend(tmp_path):
637637
assert im.getpixel((0, 0)) == (0, 255, 0, 255)
638638

639639

640+
def test_seek_after_close():
641+
im = Image.open("Tests/images/apng/delay.png")
642+
im.seek(1)
643+
im.close()
644+
645+
with pytest.raises(ValueError):
646+
im.seek(0)
647+
648+
640649
def test_constants_deprecation():
641650
for enum, prefix in {
642651
PngImagePlugin.Disposal: "APNG_DISPOSE_",

Tests/test_file_fli.py

+9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def test_closed_file():
4646
im.close()
4747

4848

49+
def test_seek_after_close():
50+
im = Image.open(animated_test_file)
51+
im.seek(1)
52+
im.close()
53+
54+
with pytest.raises(ValueError):
55+
im.seek(0)
56+
57+
4958
def test_context_manager():
5059
with warnings.catch_warnings():
5160
with Image.open(static_test_file) as im:

Tests/test_file_gif.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ def test_closed_file():
4646
im.close()
4747

4848

49+
def test_seek_after_close():
50+
im = Image.open("Tests/images/iss634.gif")
51+
im.load()
52+
im.close()
53+
54+
with pytest.raises(ValueError):
55+
im.is_animated
56+
with pytest.raises(ValueError):
57+
im.n_frames
58+
with pytest.raises(ValueError):
59+
im.seek(1)
60+
61+
4962
def test_context_manager():
5063
with warnings.catch_warnings():
5164
with Image.open(TEST_GIF) as im:
@@ -794,6 +807,9 @@ def test_comment(tmp_path):
794807
with Image.open(out) as reread:
795808
assert reread.info["comment"] == im.info["comment"].encode()
796809

810+
# Test that GIF89a is used for comments
811+
assert reread.info["version"] == b"GIF89a"
812+
797813

798814
def test_comment_over_255(tmp_path):
799815
out = str(tmp_path / "temp.gif")
@@ -804,15 +820,23 @@ def test_comment_over_255(tmp_path):
804820
im.info["comment"] = comment
805821
im.save(out)
806822
with Image.open(out) as reread:
807-
808823
assert reread.info["comment"] == comment
809824

825+
# Test that GIF89a is used for comments
826+
assert reread.info["version"] == b"GIF89a"
827+
810828

811829
def test_zero_comment_subblocks():
812830
with Image.open("Tests/images/hopper_zero_comment_subblocks.gif") as im:
813831
assert_image_equal_tofile(im, TEST_GIF)
814832

815833

834+
def test_read_multiple_comment_blocks():
835+
with Image.open("Tests/images/multiple_comments.gif") as im:
836+
# Multiple comment blocks in a frame are separated not concatenated
837+
assert im.info["comment"] == b"Test comment 1\nTest comment 2"
838+
839+
816840
def test_write_comment(tmp_path):
817841
out = str(tmp_path / "temp.gif")
818842
with Image.open("Tests/images/dispose_prev.gif") as im:

Tests/test_file_libtiff.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
hopper,
1919
mark_if_feature_version,
2020
skip_unless_feature,
21+
skip_unless_feature_version,
2122
)
2223

2324

@@ -991,6 +992,7 @@ def test_sampleformat_not_corrupted(self):
991992
with Image.open(out) as im:
992993
im.load()
993994

995+
@skip_unless_feature_version("libtiff", "4.0.4")
994996
def test_realloc_overflow(self):
995997
TiffImagePlugin.READ_LIBTIFF = True
996998
with Image.open("Tests/images/tiff_overflow_rows_per_strip.tif") as im:

Tests/test_file_mpo.py

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ def test_closed_file():
4848
im.close()
4949

5050

51+
def test_seek_after_close():
52+
im = Image.open(test_files[0])
53+
im.close()
54+
55+
with pytest.raises(ValueError):
56+
im.seek(1)
57+
58+
5159
def test_context_manager():
5260
with warnings.catch_warnings():
5361
with Image.open(test_files[0]) as im:

Tests/test_file_tga.py

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def test_cross_scan_line():
101101
with Image.open("Tests/images/cross_scan_line.tga") as im:
102102
assert_image_equal_tofile(im, "Tests/images/cross_scan_line.png")
103103

104+
with Image.open("Tests/images/cross_scan_line_truncated.tga") as im:
105+
with pytest.raises(OSError):
106+
im.load()
107+
104108

105109
def test_save(tmp_path):
106110
test_file = "Tests/images/tga_id_field.tga"

Tests/test_file_tiff.py

+16
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ def test_closed_file(self):
7070
im.load()
7171
im.close()
7272

73+
def test_seek_after_close(self):
74+
im = Image.open("Tests/images/multipage.tiff")
75+
im.close()
76+
77+
with pytest.raises(ValueError):
78+
im.n_frames
79+
with pytest.raises(ValueError):
80+
im.seek(1)
81+
7382
def test_context_manager(self):
7483
with warnings.catch_warnings():
7584
with Image.open("Tests/images/multipage.tiff") as im:
@@ -706,6 +715,13 @@ def test_save_icc_profile(self, tmp_path):
706715
with Image.open(outfile) as reloaded:
707716
assert reloaded.info["icc_profile"] == icc_profile
708717

718+
def test_save_bmp_compression(self, tmp_path):
719+
with Image.open("Tests/images/hopper.bmp") as im:
720+
assert im.info["compression"] == 0
721+
722+
outfile = str(tmp_path / "temp.tif")
723+
im.save(outfile)
724+
709725
def test_discard_icc_profile(self, tmp_path):
710726
outfile = str(tmp_path / "temp.tif")
711727

Tests/test_image_point.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22

3+
from PIL import Image
4+
35
from .helper import assert_image_equal, hopper
46

57

@@ -17,11 +19,24 @@ def test_sanity():
1719
im.point(list(range(256)))
1820
im.point(lambda x: x * 1)
1921
im.point(lambda x: x + 1)
22+
im.point(lambda x: x - 1)
2023
im.point(lambda x: x * 1 + 1)
24+
im.point(lambda x: 0.1 + 0.2 * x)
25+
im.point(lambda x: -x)
26+
im.point(lambda x: x - 0.5)
27+
im.point(lambda x: 1 - x / 2)
28+
im.point(lambda x: (2 + x) / 3)
29+
im.point(lambda x: 0.5)
30+
im.point(lambda x: x / 1)
31+
im.point(lambda x: x + x)
32+
with pytest.raises(TypeError):
33+
im.point(lambda x: x * x)
34+
with pytest.raises(TypeError):
35+
im.point(lambda x: x / x)
2136
with pytest.raises(TypeError):
22-
im.point(lambda x: x - 1)
37+
im.point(lambda x: 1 / x)
2338
with pytest.raises(TypeError):
24-
im.point(lambda x: x / 1)
39+
im.point(lambda x: x // 2)
2540

2641

2742
def test_16bit_lut():
@@ -47,3 +62,8 @@ def test_f_mode():
4762
im = hopper("F")
4863
with pytest.raises(ValueError):
4964
im.point(None)
65+
66+
67+
def test_coerce_e_deprecation():
68+
with pytest.warns(DeprecationWarning):
69+
assert Image.coerce_e(2).data == 2

Tests/test_imagefont.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ def _font_as_bytes(self):
6565
return font_bytes
6666

6767
def test_font_with_filelike(self):
68-
ImageFont.truetype(
68+
ttf = ImageFont.truetype(
6969
self._font_as_bytes(), FONT_SIZE, layout_engine=self.LAYOUT_ENGINE
7070
)
71+
ttf_copy = ttf.font_variant()
72+
assert ttf_copy.font_bytes == ttf.font_bytes
73+
7174
self._render(self._font_as_bytes())
7275
# Usage note: making two fonts from the same buffer fails.
7376
# shared_bytes = self._font_as_bytes()

depends/install_openjpeg.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# install openjpeg
33

4-
archive=openjpeg-2.4.0
4+
archive=openjpeg-2.5.0
55

66
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz
77

docs/deprecations.rst

+8
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ in Pillow 10 (2023-07-01). Upgrade to
170170
`PyQt6 <https://www.riverbankcomputing.com/static/Docs/PyQt6/>`_ or
171171
`PySide6 <https://doc.qt.io/qtforpython/>`_ instead.
172172

173+
Image.coerce_e
174+
~~~~~~~~~~~~~~
175+
176+
.. deprecated:: 9.2.0
177+
178+
This undocumented method has been deprecated and will be removed in Pillow 10
179+
(2023-07-01).
180+
173181
Removed features
174182
----------------
175183

docs/installation.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ Many of Pillow's features require external libraries:
181181

182182
* **openjpeg** provides JPEG 2000 functionality.
183183

184-
* Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1** and **2.4.0**.
184+
* Pillow has been tested with openjpeg **2.0.0**, **2.1.0**, **2.3.1**,
185+
**2.4.0** and **2.5.0**.
185186
* Pillow does **not** support the earlier **1.5** series which ships
186187
with Debian Jessie.
187188

@@ -474,11 +475,9 @@ These platforms are built and tested for every change.
474475
+----------------------------------+----------------------------+---------------------+
475476
| Ubuntu Linux 20.04 LTS (Focal) | 3.7, 3.8, 3.9, 3.10, 3.11, | x86-64 |
476477
| | PyPy3 | |
477-
| +----------------------------+---------------------+
478-
| | 3.8 | arm64v8, ppc64le, |
479-
| | | s390x |
480478
+----------------------------------+----------------------------+---------------------+
481-
| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | x86-64 |
479+
| Ubuntu Linux 22.04 LTS (Jammy) | 3.10 | arm64v8, ppc64le, |
480+
| | | s390x, x86-64 |
482481
+----------------------------------+----------------------------+---------------------+
483482
| Windows Server 2016 | 3.7 | x86-64 |
484483
+----------------------------------+----------------------------+---------------------+

docs/releasenotes/8.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ Previously, if a BMP file was too large, an ``OSError`` would be raised. Now,
174174
Dark theme for docs
175175
^^^^^^^^^^^^^^^^^^^
176176

177-
The https://pillow.readthedocs.io documentation will use a dark theme if the the user has requested the system use one. Uses the ``prefers-color-scheme`` CSS media query.
177+
The https://pillow.readthedocs.io documentation will use a dark theme if the user has requested the system use one. Uses the ``prefers-color-scheme`` CSS media query.
178178

179179

180180

0 commit comments

Comments
 (0)