Skip to content

Commit da752d6

Browse files
authored
Merge branch 'main' into feat/riscv64-wheels
2 parents bc007bc + abb1d2b commit da752d6

Some content is hidden

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

46 files changed

+969
-326
lines changed

.github/workflows/test-docker.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@ jobs:
4343
ubuntu-24.04-noble-s390x,
4444
# Then run the remainder
4545
alpine,
46-
amazon-2-amd64,
4746
amazon-2023-amd64,
4847
arch,
4948
centos-stream-9-amd64,
5049
centos-stream-10-amd64,
51-
debian-12-bookworm-x86,
52-
debian-12-bookworm-amd64,
5350
debian-13-trixie-x86,
5451
debian-13-trixie-amd64,
55-
fedora-42-amd64,
5652
fedora-43-amd64,
5753
gentoo,
5854
ubuntu-22.04-jammy-amd64,

.github/workflows/wheels-dependencies.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ ARCHIVE_SDIR=pillow-depends-main
9393
FREETYPE_VERSION=2.14.3
9494
HARFBUZZ_VERSION=13.2.1
9595
LIBPNG_VERSION=1.6.56
96-
JPEGTURBO_VERSION=3.1.3
96+
JPEGTURBO_VERSION=3.1.4.1
9797
OPENJPEG_VERSION=2.5.4
98-
XZ_VERSION=5.8.2
98+
XZ_VERSION=5.8.3
9999
ZSTD_VERSION=1.5.7
100100
TIFF_VERSION=4.7.1
101101
LCMS2_VERSION=2.18
@@ -178,7 +178,6 @@ function build_libavif {
178178
build_simple nasm 2.16.03 https://www.nasm.us/pub/nasm/releasebuilds/2.16.03
179179
fi
180180

181-
local build_type=MinSizeRel
182181
local build_shared=ON
183182
local lto=ON
184183

@@ -195,9 +194,6 @@ function build_libavif {
195194
build_shared=OFF
196195
fi
197196
else
198-
if [[ "$MB_ML_VER" == 2014 ]] && [[ "$PLAT" == "x86_64" ]]; then
199-
build_type=Release
200-
fi
201197
libavif_cmake_flags=(-DCMAKE_SHARED_LINKER_FLAGS_INIT="-Wl,--strip-all,-z,relro,-z,now")
202198
fi
203199
if [[ -n "$IOS_SDK" ]] && [[ "$PLAT" == "x86_64" ]]; then
@@ -226,7 +222,7 @@ function build_libavif {
226222
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=$lto \
227223
-DCMAKE_C_VISIBILITY_PRESET=hidden \
228224
-DCMAKE_CXX_VISIBILITY_PRESET=hidden \
229-
-DCMAKE_BUILD_TYPE=$build_type \
225+
-DCMAKE_BUILD_TYPE=MinSizeRel \
230226
"${libavif_cmake_flags[@]}" \
231227
$HOST_CMAKE_FLAGS . )
232228

.github/workflows/wheels.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ concurrency:
3939
cancel-in-progress: true
4040

4141
env:
42-
EXPECTED_DISTS: 91
42+
EXPECTED_DISTS: 75
4343
FORCE_COLOR: 1
4444

4545
jobs:
@@ -74,22 +74,22 @@ jobs:
7474
os: macos-latest
7575
cibw_arch: arm64
7676
macosx_deployment_target: "11.0"
77-
- name: "manylinux2014 and musllinux x86_64"
77+
- name: "manylinux_2_28 x86_64"
7878
platform: linux
7979
os: ubuntu-latest
8080
cibw_arch: x86_64
81-
manylinux: "manylinux2014"
82-
- name: "manylinux_2_28 x86_64"
81+
build: "*manylinux*"
82+
- name: "musllinux x86_64"
8383
platform: linux
8484
os: ubuntu-latest
8585
cibw_arch: x86_64
86-
build: "*manylinux*"
87-
- name: "manylinux2014 and musllinux aarch64"
86+
build: "*musllinux*"
87+
- name: "manylinux_2_28 aarch64"
8888
platform: linux
8989
os: ubuntu-24.04-arm
9090
cibw_arch: aarch64
91-
manylinux: "manylinux2014"
92-
- name: "manylinux_2_28 aarch64"
91+
build: "*manylinux*"
92+
- name: "musllinux aarch64"
9393
platform: linux
9494
os: ubuntu-24.04-arm
9595
cibw_arch: aarch64
@@ -140,11 +140,7 @@ jobs:
140140
CIBW_ARCHS: ${{ matrix.cibw_arch }}
141141
CIBW_BUILD: ${{ matrix.build }}
142142
CIBW_ENABLE: cpython-prerelease cpython-freethreading pypy
143-
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.manylinux }}
144-
CIBW_MANYLINUX_PYPY_AARCH64_IMAGE: ${{ matrix.manylinux }}
145-
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: ${{ matrix.manylinux }}
146143
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ matrix.manylinux }}
147-
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux }}
148144
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
149145

150146
- uses: actions/upload-artifact@v6

Tests/images/pal8_offset.bmp

-9.04 KB
Binary file not shown.
496 Bytes
Binary file not shown.
202 Bytes
Binary file not shown.

Tests/images/trailer_loop.pdf

1.78 KB
Binary file not shown.

Tests/test_file_bmp.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_fallback_if_mmap_errors() -> None:
4242
# This image has been truncated,
4343
# so that the buffer is not large enough when using mmap
4444
with Image.open("Tests/images/mmap_error.bmp") as im:
45-
assert_image_equal_tofile(im, "Tests/images/pal8_offset.bmp")
45+
assert_image_equal_tofile(im, "Tests/images/bmp/g/pal8.bmp")
4646

4747

4848
def test_save_to_bytes() -> None:
@@ -238,11 +238,21 @@ def test_unsupported_bmp_bitfields_layout() -> None:
238238
Image.open(fp)
239239

240240

241-
def test_offset() -> None:
242-
# This image has been hexedited
243-
# to exclude the palette size from the pixel data offset
244-
with Image.open("Tests/images/pal8_offset.bmp") as im:
245-
assert_image_equal_tofile(im, "Tests/images/bmp/g/pal8.bmp")
241+
@pytest.mark.parametrize(
242+
"offset, path",
243+
(
244+
(26, "pal8os2.bmp"),
245+
(54, "pal8.bmp"),
246+
),
247+
)
248+
def test_offset(offset: int, path: str) -> None:
249+
image_path = "Tests/images/bmp/g/" + path
250+
# Exclude the palette size from the pixel data offset
251+
with open(image_path, "rb") as fp:
252+
data = fp.read()
253+
data = data[:10] + o32(offset) + data[14:]
254+
with Image.open(io.BytesIO(data)) as im:
255+
assert_image_equal_tofile(im, image_path)
246256

247257

248258
def test_use_raw_alpha(monkeypatch: pytest.MonkeyPatch) -> None:

Tests/test_file_libtiff.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,15 @@ def test_strip_planar_16bit_RGBa(self) -> None:
10551055
with Image.open("Tests/images/tiff_strip_planar_16bit_RGBa.tiff") as im:
10561056
assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png")
10571057

1058+
def test_separate_planar_extra_samples(self, tmp_path: Path) -> None:
1059+
out = tmp_path / "temp.tif"
1060+
with Image.open("Tests/images/separate_planar_extra_samples.tiff") as im:
1061+
assert im.mode == "L"
1062+
1063+
im.save(out)
1064+
with Image.open(out) as reloaded:
1065+
assert reloaded.mode == "L"
1066+
10581067
@pytest.mark.parametrize("compression", (None, "jpeg"))
10591068
def test_block_tile_tags(self, compression: str | None, tmp_path: Path) -> None:
10601069
im = hopper()

Tests/test_file_psd.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
from __future__ import annotations
22

3+
import sys
34
import warnings
45

56
import pytest
67

78
from PIL import Image, PsdImagePlugin
89

9-
from .helper import assert_image_equal_tofile, assert_image_similar, hopper, is_pypy
10+
from .helper import (
11+
assert_image_equal_tofile,
12+
assert_image_similar,
13+
hopper,
14+
is_pypy,
15+
)
1016

1117
test_file = "Tests/images/hopper.psd"
1218

@@ -85,6 +91,11 @@ def test_eoferror() -> None:
8591
# Test that seeking to the last frame does not raise an error
8692
im.seek(n_frames - 1)
8793

94+
# Test seeking past the last frame without calling n_frames first
95+
with Image.open(test_file) as im:
96+
with pytest.raises(EOFError):
97+
im.seek(3)
98+
8899

89100
def test_seek_tell() -> None:
90101
with Image.open(test_file) as im:
@@ -199,3 +210,17 @@ def test_bounds_crash(test_file: str) -> None:
199210

200211
with pytest.raises(ValueError):
201212
im.load()
213+
214+
215+
def test_bounds_crash_overflow() -> None:
216+
with Image.open("Tests/images/psd-oob-write-overflow.psd") as im:
217+
assert isinstance(im, PsdImagePlugin.PsdImageFile)
218+
im.load()
219+
if sys.maxsize <= 2**32:
220+
with pytest.raises(OverflowError):
221+
im.seek(im.n_frames)
222+
else:
223+
im.seek(im.n_frames)
224+
225+
with pytest.raises(ValueError):
226+
im.load()

0 commit comments

Comments
 (0)