Skip to content

Commit

Permalink
Merge branch 'main' into setuptools_scm
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 24, 2023
2 parents 3f15c21 + 41e45b5 commit 1d134dd
Show file tree
Hide file tree
Showing 289 changed files with 583 additions and 143 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Lint

on: [push, pull_request, workflow_dispatch]

env:
FORCE_COLOR: 1

permissions:
contents: read

Expand Down Expand Up @@ -46,3 +49,6 @@ jobs:
run: tox -e lint
env:
PRE_COMMIT_COLOR: always

- name: Mypy
run: tox -e mypy
2 changes: 2 additions & 0 deletions .github/workflows/system-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Requested here:
https://github.com/actions/virtual-environments/issues/79
"""
from __future__ import annotations

import os
import platform
import sys
Expand Down
15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Changelog (Pillow)
10.2.0 (unreleased)
-------------------

- Attempt memory mapping when tile args is a string #7565
[radarhere]

- Fill identical pixels with transparency in subsequent frames when saving GIF #7568
[radarhere]

- Corrected duration when combining multiple GIF frames into single frame #7521
[radarhere]

- Handle disposing GIF background from outside palette #7515
[radarhere]

- Seek past the data when skipping a PSD layer #7483
[radarhere]

- Import plugins relative to the module #7576
[deliangyang, jaxx0n]

Expand Down
1 change: 1 addition & 0 deletions Tests/32bit_segfault_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations

import sys

Expand Down
1 change: 1 addition & 0 deletions Tests/bench_cffi_access.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import time

from PIL import PyAccess
Expand Down
1 change: 1 addition & 0 deletions Tests/check_fli_oob.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations

from PIL import Image

Expand Down
1 change: 1 addition & 0 deletions Tests/check_fli_overflow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from PIL import Image

TEST_FILE = "Tests/images/fli_overflow.fli"
Expand Down
1 change: 1 addition & 0 deletions Tests/check_icns_dos.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Tests potential DOS of IcnsImagePlugin with 0 length block.
# Run from anywhere that PIL is importable.
from __future__ import annotations

from io import BytesIO

Expand Down
1 change: 1 addition & 0 deletions Tests/check_imaging_leaks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import pytest

from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/check_j2k_dos.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Tests potential DOS of Jpeg2kImagePlugin with 0 length block.
# Run from anywhere that PIL is importable.
from __future__ import annotations

from io import BytesIO

Expand Down
1 change: 1 addition & 0 deletions Tests/check_j2k_leaks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from io import BytesIO

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/check_j2k_overflow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/check_jp2_overflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# the output should be empty. There may be python issues
# in the valgrind especially if run in a debug python
# version.
from __future__ import annotations


from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/check_jpeg_leaks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from io import BytesIO

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/check_large_memory.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import sys

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/check_large_memory_numpy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import sys

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/check_libtiff_segfault.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/check_png_dos.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import zlib
from io import BytesIO

Expand Down
1 change: 1 addition & 0 deletions Tests/check_release_notes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import sys
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions Tests/check_wheel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import sys

from PIL import features
Expand Down
1 change: 1 addition & 0 deletions Tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import io


Expand Down
1 change: 1 addition & 0 deletions Tests/createfontdatachunk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
from __future__ import annotations
import base64
import os

Expand Down
1 change: 1 addition & 0 deletions Tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Helper functions.
"""
from __future__ import annotations

import logging
import os
Expand Down
Binary file added Tests/images/background_outside_palette.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tests/images/five_channels.psd
Binary file not shown.
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzz_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations


import atheris
Expand Down
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzz_pillow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations


import atheris
Expand Down
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzzers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import io
import warnings

Expand Down
1 change: 1 addition & 0 deletions Tests/oss-fuzz/test_fuzzers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import subprocess
import sys

Expand Down
1 change: 1 addition & 0 deletions Tests/test_000_sanity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from PIL import Image


Expand Down
1 change: 1 addition & 0 deletions Tests/test_binary.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from PIL import _binary


Expand Down
1 change: 1 addition & 0 deletions Tests/test_bmp_reference.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import os
import warnings

Expand Down
1 change: 1 addition & 0 deletions Tests/test_box_blur.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image, ImageFilter
Expand Down
1 change: 1 addition & 0 deletions Tests/test_color_lut.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from array import array

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_core_resources.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import sys

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_decompression_bomb.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_deprecate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import _deprecate
Expand Down
1 change: 1 addition & 0 deletions Tests/test_features.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import io
import re

Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_apng.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image, ImageSequence, PngImagePlugin
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_blp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_bmp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import io

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_bufrstub.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import BufrStubImagePlugin, Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_container.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import ContainerIO, Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_cur.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import CurImagePlugin, Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_dcx.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import warnings

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_dds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test DdsImagePlugin"""
from __future__ import annotations
from io import BytesIO

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_eps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import io

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_fits.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from io import BytesIO

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_fli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import warnings

import pytest
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_fpx.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_ftex.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import FtexImagePlugin, Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_gbr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import GbrImagePlugin, Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_gd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import GdImageFile, UnidentifiedImageError
Expand Down
39 changes: 37 additions & 2 deletions Tests/test_file_gif.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import warnings
from io import BytesIO

Expand Down Expand Up @@ -217,6 +218,27 @@ def test_optimize_if_palette_can_be_reduced_by_half():
assert len(reloaded.palette.palette) // 3 == colors


def test_full_palette_second_frame(tmp_path):
out = str(tmp_path / "temp.gif")
im = Image.new("P", (1, 256))

full_palette_im = Image.new("P", (1, 256))
for i in range(256):
full_palette_im.putpixel((0, i), i)
full_palette_im.palette = ImagePalette.ImagePalette(
"RGB", bytearray(i // 3 for i in range(768))
)
full_palette_im.palette.dirty = 1

im.save(out, save_all=True, append_images=[full_palette_im])

with Image.open(out) as reloaded:
reloaded.seek(1)

for i in range(256):
reloaded.getpixel((0, i)) == i


def test_roundtrip(tmp_path):
out = str(tmp_path / "temp.gif")
im = hopper()
Expand Down Expand Up @@ -856,7 +878,14 @@ def test_identical_frames(tmp_path):


@pytest.mark.parametrize(
"duration", ([1000, 1500, 2000, 4000], (1000, 1500, 2000, 4000), 8500)
"duration",
(
[1000, 1500, 2000],
(1000, 1500, 2000),
# One more duration than the number of frames
[1000, 1500, 2000, 4000],
1500,
),
)
def test_identical_frames_to_single_frame(duration, tmp_path):
out = str(tmp_path / "temp.gif")
Expand All @@ -872,7 +901,7 @@ def test_identical_frames_to_single_frame(duration, tmp_path):
assert reread.n_frames == 1

# Assert that the new duration is the total of the identical frames
assert reread.info["duration"] == 8500
assert reread.info["duration"] == 4500


def test_loop_none(tmp_path):
Expand Down Expand Up @@ -1142,6 +1171,12 @@ def test_rgba_transparency(tmp_path):
assert_image_equal(hopper("P").convert("RGB"), reloaded)


def test_background_outside_palettte(tmp_path):
with Image.open("Tests/images/background_outside_palette.gif") as im:
im.seek(1)
assert im.info["background"] == 255


def test_bbox(tmp_path):
out = str(tmp_path / "temp.gif")

Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_gimpgradient.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from PIL import GimpGradientFile, ImagePalette


Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_gimppalette.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL.GimpPaletteFile import GimpPaletteFile
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_gribstub.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import GribStubImagePlugin, Image
Expand Down
1 change: 1 addition & 0 deletions Tests/test_file_hdf5stub.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
import pytest

from PIL import Hdf5StubImagePlugin, Image
Expand Down

0 comments on commit 1d134dd

Please sign in to comment.