Skip to content

Commit 2eca298

Browse files
committed
Merge branch 'main' into pyaccess_pa
2 parents a37593f + b607e83 commit 2eca298

45 files changed

Lines changed: 1222 additions & 1157 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ci/install.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ python3 -m pip install -U pytest
3535
python3 -m pip install -U pytest-cov
3636
python3 -m pip install -U pytest-timeout
3737
python3 -m pip install pyroma
38-
python3 -m pip install test-image-results
3938

4039
if [[ $(uname) != CYGWIN* ]]; then
41-
# TODO Remove condition when NumPy supports 3.11
42-
if ! [ "$GHA_PYTHON_VERSION" == "3.11-dev" ]; then python3 -m pip install numpy ; fi
40+
python3 -m pip install numpy
4341

4442
# PyQt6 doesn't support PyPy3
4543
if [[ $GHA_PYTHON_VERSION == 3.* ]]; then

.github/workflows/cifuzz.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- "**.h"
1212
workflow_dispatch:
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
Fuzzing:
1619
runs-on: ubuntu-latest

.github/workflows/macos-install.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ python3 -m pip install -U pytest
1212
python3 -m pip install -U pytest-cov
1313
python3 -m pip install -U pytest-timeout
1414
python3 -m pip install pyroma
15-
python3 -m pip install test-image-results
1615

1716
echo -e "[openblas]\nlibraries = openblas\nlibrary_dirs = /usr/local/opt/openblas/lib" >> ~/.numpy-site.cfg
18-
# TODO Remove condition when NumPy supports 3.11
19-
if ! [ "$GHA_PYTHON_VERSION" == "3.11-dev" ]; then python3 -m pip install numpy ; fi
17+
python3 -m pip install numpy
2018

2119
# extra test images
2220
pushd depends && ./install_extra_test_images.sh && popd

.github/workflows/test-cygwin.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Test Cygwin
22

33
on: [push, pull_request, workflow_dispatch]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
build:
710
runs-on: windows-latest

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ Changelog (Pillow)
55
9.3.0 (unreleased)
66
------------------
77

8+
- Open 1 bit EPS in mode 1 #6499
9+
[radarhere]
10+
11+
- Removed support for tkinter before Python 1.5.2 #6549
12+
[radarhere]
13+
14+
- Allow default ImageDraw font to be set #6484
15+
[radarhere, hugovk]
16+
817
- Save 1 mode PDF using CCITTFaxDecode filter #6470
918
[radarhere]
1019

Tests/images/1.eps

44.8 KB
Binary file not shown.

Tests/images/mmap_error.bmp

9.04 KB
Binary file not shown.

Tests/test_file_apng.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,21 +325,23 @@ def open():
325325
pytest.warns(UserWarning, open)
326326

327327

328-
def test_apng_sequence_errors():
329-
test_files = [
328+
@pytest.mark.parametrize(
329+
"test_file",
330+
(
330331
"sequence_start.png",
331332
"sequence_gap.png",
332333
"sequence_repeat.png",
333334
"sequence_repeat_chunk.png",
334335
"sequence_reorder.png",
335336
"sequence_reorder_chunk.png",
336337
"sequence_fdat_fctl.png",
337-
]
338-
for f in test_files:
339-
with pytest.raises(SyntaxError):
340-
with Image.open(f"Tests/images/apng/{f}") as im:
341-
im.seek(im.n_frames - 1)
342-
im.load()
338+
),
339+
)
340+
def test_apng_sequence_errors(test_file):
341+
with pytest.raises(SyntaxError):
342+
with Image.open(f"Tests/images/apng/{test_file}") as im:
343+
im.seek(im.n_frames - 1)
344+
im.load()
343345

344346

345347
def test_apng_save(tmp_path):

Tests/test_file_bmp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ def test_invalid_file():
3939
BmpImagePlugin.BmpImageFile(fp)
4040

4141

42+
def test_fallback_if_mmap_errors():
43+
# This image has been truncated,
44+
# so that the buffer is not large enough when using mmap
45+
with Image.open("Tests/images/mmap_error.bmp") as im:
46+
assert_image_equal_tofile(im, "Tests/images/pal8_offset.bmp")
47+
48+
4249
def test_save_to_bytes():
4350
output = io.BytesIO()
4451
im = hopper()

Tests/test_file_container.py

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from PIL import ContainerIO, Image
24

35
from .helper import hopper
@@ -59,89 +61,89 @@ def test_seek_mode_2():
5961
assert container.tell() == 100
6062

6163

62-
def test_read_n0():
64+
@pytest.mark.parametrize("bytesmode", (True, False))
65+
def test_read_n0(bytesmode):
6366
# Arrange
64-
for bytesmode in (True, False):
65-
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
66-
container = ContainerIO.ContainerIO(fh, 22, 100)
67+
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
68+
container = ContainerIO.ContainerIO(fh, 22, 100)
6769

68-
# Act
69-
container.seek(81)
70-
data = container.read()
70+
# Act
71+
container.seek(81)
72+
data = container.read()
7173

72-
# Assert
73-
if bytesmode:
74-
data = data.decode()
75-
assert data == "7\nThis is line 8\n"
74+
# Assert
75+
if bytesmode:
76+
data = data.decode()
77+
assert data == "7\nThis is line 8\n"
7678

7779

78-
def test_read_n():
80+
@pytest.mark.parametrize("bytesmode", (True, False))
81+
def test_read_n(bytesmode):
7982
# Arrange
80-
for bytesmode in (True, False):
81-
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
82-
container = ContainerIO.ContainerIO(fh, 22, 100)
83+
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
84+
container = ContainerIO.ContainerIO(fh, 22, 100)
8385

84-
# Act
85-
container.seek(81)
86-
data = container.read(3)
86+
# Act
87+
container.seek(81)
88+
data = container.read(3)
8789

88-
# Assert
89-
if bytesmode:
90-
data = data.decode()
91-
assert data == "7\nT"
90+
# Assert
91+
if bytesmode:
92+
data = data.decode()
93+
assert data == "7\nT"
9294

9395

94-
def test_read_eof():
96+
@pytest.mark.parametrize("bytesmode", (True, False))
97+
def test_read_eof(bytesmode):
9598
# Arrange
96-
for bytesmode in (True, False):
97-
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
98-
container = ContainerIO.ContainerIO(fh, 22, 100)
99+
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
100+
container = ContainerIO.ContainerIO(fh, 22, 100)
99101

100-
# Act
101-
container.seek(100)
102-
data = container.read()
102+
# Act
103+
container.seek(100)
104+
data = container.read()
103105

104-
# Assert
105-
if bytesmode:
106-
data = data.decode()
107-
assert data == ""
106+
# Assert
107+
if bytesmode:
108+
data = data.decode()
109+
assert data == ""
108110

109111

110-
def test_readline():
112+
@pytest.mark.parametrize("bytesmode", (True, False))
113+
def test_readline(bytesmode):
111114
# Arrange
112-
for bytesmode in (True, False):
113-
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
114-
container = ContainerIO.ContainerIO(fh, 0, 120)
115+
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
116+
container = ContainerIO.ContainerIO(fh, 0, 120)
115117

116-
# Act
117-
data = container.readline()
118+
# Act
119+
data = container.readline()
118120

119-
# Assert
120-
if bytesmode:
121-
data = data.decode()
122-
assert data == "This is line 1\n"
121+
# Assert
122+
if bytesmode:
123+
data = data.decode()
124+
assert data == "This is line 1\n"
123125

124126

125-
def test_readlines():
127+
@pytest.mark.parametrize("bytesmode", (True, False))
128+
def test_readlines(bytesmode):
126129
# Arrange
127-
for bytesmode in (True, False):
128-
expected = [
129-
"This is line 1\n",
130-
"This is line 2\n",
131-
"This is line 3\n",
132-
"This is line 4\n",
133-
"This is line 5\n",
134-
"This is line 6\n",
135-
"This is line 7\n",
136-
"This is line 8\n",
137-
]
138-
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
139-
container = ContainerIO.ContainerIO(fh, 0, 120)
140-
141-
# Act
142-
data = container.readlines()
143-
144-
# Assert
145-
if bytesmode:
146-
data = [line.decode() for line in data]
147-
assert data == expected
130+
expected = [
131+
"This is line 1\n",
132+
"This is line 2\n",
133+
"This is line 3\n",
134+
"This is line 4\n",
135+
"This is line 5\n",
136+
"This is line 6\n",
137+
"This is line 7\n",
138+
"This is line 8\n",
139+
]
140+
with open(TEST_FILE, "rb" if bytesmode else "r") as fh:
141+
container = ContainerIO.ContainerIO(fh, 0, 120)
142+
143+
# Act
144+
data = container.readlines()
145+
146+
# Assert
147+
if bytesmode:
148+
data = [line.decode() for line in data]
149+
assert data == expected

0 commit comments

Comments
 (0)