Merge branch 'master' into anchor

This commit is contained in:
Andrew Murray 2020-08-09 21:02:08 +10:00 committed by GitHub
commit 5378d262e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
147 changed files with 331 additions and 199 deletions

View File

@ -9,35 +9,35 @@ repos:
types: []
- repo: https://github.com/timothycrosley/isort
rev: 7c29dd9d55161704cfc45998c6f5c2c43d39264b # frozen: 4.3.21
rev: 9ae09866e278fbc6ec0383ccb16b5c84e78e6e4d # frozen: 5.3.2
hooks:
- id: isort
- repo: https://github.com/asottile/yesqa
rev: b13a51aa54142c59219c764e9f9362c049b439ed # frozen: v1.2.0
rev: 7a009f3ee493c796827ee334f9058b110a0e0db8 # frozen: v1.2.1
hooks:
- id: yesqa
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: ffbd448645bad2e7ca13f96fca5830058d27ccd5 # frozen: v1.1.7
rev: f30f4974a08a6b2f6a1eeaf30a4d501cf909163a # frozen: v1.1.9
hooks:
- id: remove-tabs
exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.opt$)
- repo: https://gitlab.com/pycqa/flake8
rev: 735cfe7e1c57a8e05f660ba75de72313005af54a # frozen: 3.8.2
rev: 05f6544aef321e2fee03a1277ce2eef8880fb927 # frozen: 3.8.3
hooks:
- id: flake8
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 0d7d077d6ed5624854f93ac601739c1804ebeb98 # frozen: v1.5.1
rev: 20b9ac745c5adaab12b845b3564c773dcc051d0e # frozen: v1.5.2
hooks:
- id: python-check-blanket-noqa
- id: rst-backticks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: ebc15addedad713c86ef18ae9632c88e187dd0af # frozen: v3.1.0
rev: e1668fe86af3810fbca72b8653fe478e66a0afdc # frozen: v3.2.0
hooks:
- id: check-merge-conflict
- id: check-yaml

View File

@ -5,6 +5,9 @@ Changelog (Pillow)
8.0.0 (unreleased)
------------------
- Remove long-deprecated Image.py functions #4798
[hugovk, nulano, radarhere]
- Add MIME type to PsdImagePlugin #4788
[samamorgan]

View File

@ -1,7 +1,6 @@
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: clean coverage doc docserve help inplace install install-req release-test sdist test upload upload-test
.DEFAULT_GOAL := release-test
.PHONY: clean
clean:
python3 setup.py clean
rm src/PIL/*.so || true
@ -9,28 +8,34 @@ clean:
find . -name __pycache__ | xargs rm -r || true
BRANCHES=`git branch -a | grep -v HEAD | grep -v master | grep remote`
.PHONY: co
co:
-for i in $(BRANCHES) ; do \
git checkout -t $$i ; \
done
.PHONY: coverage
coverage:
pytest -qq
rm -r htmlcov || true
coverage report
.PHONY: doc
doc:
$(MAKE) -C docs html
.PHONY: doccheck
doccheck:
$(MAKE) -C docs html
# Don't make our tests rely on the links in the docs being up every single build.
# We don't control them. But do check, and update them to the target of their redirects.
$(MAKE) -C docs linkcheck || true
.PHONY: docserve
docserve:
cd docs/_build/html && python3 -mSimpleHTTPServer 2> /dev/null&
.PHONY: help
help:
@echo "Welcome to Pillow development. Please use \`make <target>\` where <target> is one of"
@echo " clean remove build products"
@ -48,17 +53,21 @@ help:
@echo " upload build and upload sdists to PyPI"
@echo " upload-test build and upload sdists to test.pythonpackages.com"
.PHONY: inplace
inplace: clean
python3 setup.py develop build_ext --inplace
.PHONY: install
install:
python3 setup.py install
python3 selftest.py
.PHONY: install-coverage
install-coverage:
CFLAGS="-coverage" python3 setup.py build_ext install
python3 selftest.py
.PHONY: debug
debug:
# make a debug version if we don't have a -dbg python. Leaves in symbols
# for our stuff, kills optimization, and redirects to dev null so we
@ -66,13 +75,16 @@ debug:
make clean > /dev/null
CFLAGS='-g -O0' python3 setup.py build_ext install > /dev/null
.PHONY: install-req
install-req:
python3 -m pip install -r requirements.txt
.PHONY: install-venv
install-venv:
virtualenv .
bin/pip install -r requirements.txt
.PHONY: release-test
release-test:
$(MAKE) install-req
python3 setup.py develop
@ -84,22 +96,14 @@ release-test:
pyroma .
viewdoc
.PHONY: sdist
sdist:
python3 setup.py sdist --format=gztar
.PHONY: test
test:
pytest -qq
# https://docs.python.org/3/distutils/packageindex.html#the-pypirc-file
upload-test:
# [test]
# username:
# password:
# repository = http://test.pythonpackages.com
python3 setup.py sdist --format=gztar upload -r test
upload:
python3 setup.py sdist --format=gztar upload
.PHONY: readme
readme:
viewdoc

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python
import pytest
from PIL import Image
from .helper import is_win32
@ -11,7 +12,7 @@ pytestmark = pytest.mark.skipif(is_win32(), reason="requires Unix or macOS")
def _get_mem_usage():
from resource import getpagesize, getrusage, RUSAGE_SELF
from resource import RUSAGE_SELF, getpagesize, getrusage
mem = getrusage(RUSAGE_SELF).ru_maxrss
return mem * getpagesize() / 1024 / 1024

View File

@ -1,6 +1,7 @@
from io import BytesIO
import pytest
from PIL import Image
from .helper import is_win32, skip_unless_feature
@ -18,7 +19,7 @@ pytestmark = [
def test_leak_load():
from resource import setrlimit, RLIMIT_AS, RLIMIT_STACK
from resource import RLIMIT_AS, RLIMIT_STACK, setrlimit
setrlimit(RLIMIT_STACK, (stack_size, stack_size))
setrlimit(RLIMIT_AS, (mem_limit, mem_limit))
@ -28,7 +29,7 @@ def test_leak_load():
def test_leak_save():
from resource import setrlimit, RLIMIT_AS, RLIMIT_STACK
from resource import RLIMIT_AS, RLIMIT_STACK, setrlimit
setrlimit(RLIMIT_STACK, (stack_size, stack_size))
setrlimit(RLIMIT_AS, (mem_limit, mem_limit))

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image

View File

@ -1,6 +1,7 @@
import sys
import pytest
from PIL import Image
# This test is not run automatically.

View File

@ -1,6 +1,7 @@
import sys
import pytest
from PIL import Image
# This test is not run automatically.

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
TEST_FILE = "Tests/images/libtiff_segfault.tif"

View File

@ -11,6 +11,7 @@ import tempfile
from io import BytesIO
import pytest
from PIL import Image, ImageMath, features
logger = logging.getLogger(__name__)
@ -184,7 +185,7 @@ class PillowLeakTestCase:
:returns: memory usage in kilobytes
"""
from resource import getrusage, RUSAGE_SELF
from resource import RUSAGE_SELF, getrusage
mem = getrusage(RUSAGE_SELF).ru_maxrss
if sys.platform == "darwin":

View File

@ -1,6 +1,7 @@
import os
import pytest
from PIL import Image
from .helper import assert_image_similar

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageFilter
sample = Image.new("L", (7, 5))

View File

@ -1,6 +1,7 @@
from array import array
import pytest
from PIL import Image, ImageFilter
from .helper import assert_image_equal

View File

@ -1,6 +1,7 @@
import sys
import pytest
from PIL import Image
from .helper import is_pypy

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import hopper

View File

@ -2,6 +2,7 @@ import io
import re
import pytest
from PIL import features
from .helper import skip_unless_feature

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageSequence, PngImagePlugin

View File

@ -1,6 +1,7 @@
import io
import pytest
from PIL import BmpImagePlugin, Image
from .helper import assert_image_equal, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import BufrStubImagePlugin, Image
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import CurImagePlugin, Image
TEST_FILE = "Tests/images/deerstalker.cur"

View File

@ -1,4 +1,5 @@
import pytest
from PIL import DcxImagePlugin, Image
from .helper import assert_image_equal, hopper, is_pypy

View File

@ -2,6 +2,7 @@
from io import BytesIO
import pytest
from PIL import DdsImagePlugin, Image
from .helper import assert_image_equal

View File

@ -1,6 +1,7 @@
import io
import pytest
from PIL import EpsImagePlugin, Image, features
from .helper import assert_image_similar, hopper, skip_unless_feature

View File

@ -1,4 +1,5 @@
import pytest
from PIL import FitsStubImagePlugin, Image
TEST_FILE = "Tests/images/hopper.fits"

View File

@ -1,4 +1,5 @@
import pytest
from PIL import FliImagePlugin, Image
from .helper import assert_image_equal, is_pypy

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
FpxImagePlugin = pytest.importorskip(

View File

@ -1,4 +1,5 @@
import pytest
from PIL import GbrImagePlugin, Image
from .helper import assert_image_equal

View File

@ -1,4 +1,5 @@
import pytest
from PIL import GdImageFile, UnidentifiedImageError
TEST_GD_FILE = "Tests/images/hopper.gd"

View File

@ -1,6 +1,7 @@
from io import BytesIO
import pytest
from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette, features
from .helper import (

View File

@ -1,4 +1,5 @@
import pytest
from PIL.GimpPaletteFile import GimpPaletteFile

View File

@ -1,4 +1,5 @@
import pytest
from PIL import GribStubImagePlugin, Image
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Hdf5StubImagePlugin, Image
TEST_FILE = "Tests/images/hdf5.h5"

View File

@ -2,6 +2,7 @@ import io
import sys
import pytest
from PIL import IcnsImagePlugin, Image, features
from .helper import assert_image_equal, assert_image_similar

View File

@ -1,6 +1,7 @@
import io
import pytest
from PIL import IcoImagePlugin, Image, ImageDraw
from .helper import assert_image_equal, hopper

View File

@ -1,6 +1,7 @@
import filecmp
import pytest
from PIL import Image, ImImagePlugin
from .helper import assert_image_equal, hopper, is_pypy

View File

@ -3,6 +3,7 @@ import re
from io import BytesIO
import pytest
from PIL import (
ExifTags,
Image,

View File

@ -2,6 +2,7 @@ import re
from io import BytesIO
import pytest
from PIL import Image, ImageFile, Jpeg2KImagePlugin, features
from .helper import (

View File

@ -1,13 +1,13 @@
import base64
import io
import itertools
import logging
import os
import re
from collections import namedtuple
from ctypes import c_float
import pytest
from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags, features
from .helper import (
@ -19,8 +19,6 @@ from .helper import (
skip_unless_feature,
)
logger = logging.getLogger(__name__)
@skip_unless_feature("libtiff")
class LibTiffTestCase:

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, McIdasImagePlugin
from .helper import assert_image_equal

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImagePalette
from .helper import assert_image_similar, hopper, skip_unless_feature

View File

@ -1,6 +1,7 @@
from io import BytesIO
import pytest
from PIL import Image
from .helper import assert_image_similar, is_pypy, skip_unless_feature

View File

@ -1,6 +1,7 @@
import os
import pytest
from PIL import Image, MspImagePlugin
from .helper import assert_image_equal, hopper

View File

@ -2,6 +2,7 @@ import os.path
import subprocess
import pytest
from PIL import Image
from .helper import IMCONVERT, assert_image_equal, hopper, imagemagick_available

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageFile, PcxImagePlugin
from .helper import assert_image_equal, hopper

View File

@ -5,6 +5,7 @@ import tempfile
import time
import pytest
from PIL import Image, PdfParser
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, PixarImagePlugin
from .helper import assert_image_similar, hopper

View File

@ -3,6 +3,7 @@ import zlib
from io import BytesIO
import pytest
from PIL import Image, ImageFile, PngImagePlugin, features
from .helper import (

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, PsdImagePlugin
from .helper import assert_image_similar, hopper, is_pypy

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, SgiImagePlugin
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -2,6 +2,7 @@ import tempfile
from io import BytesIO
import pytest
from PIL import Image, ImageSequence, SpiderImagePlugin
from .helper import assert_image_equal, hopper, is_pypy

View File

@ -1,6 +1,7 @@
import os
import pytest
from PIL import Image, SunImagePlugin
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, TarIO, features
from .helper import is_pypy

View File

@ -3,6 +3,7 @@ from glob import glob
from itertools import product
import pytest
from PIL import Image
from .helper import assert_image_equal, hopper

View File

@ -1,8 +1,8 @@
import logging
import os
from io import BytesIO
import pytest
from PIL import Image, TiffImagePlugin
from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION
@ -16,8 +16,6 @@ from .helper import (
is_win32,
)
logger = logging.getLogger(__name__)
class TestFileTiff:
def test_sanity(self, tmp_path):

View File

@ -2,6 +2,7 @@ import io
import struct
import pytest
from PIL import Image, TiffImagePlugin, TiffTags
from PIL.TiffImagePlugin import IFDRational

View File

@ -2,6 +2,7 @@ import io
import re
import pytest
from PIL import Image, WebPImagePlugin, features
from .helper import (

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import (

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import assert_image_equal, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, WmfImagePlugin
from .helper import assert_image_similar, hopper

View File

@ -1,6 +1,7 @@
from io import BytesIO
import pytest
from PIL import Image
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, XpmImagePlugin
from .helper import assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, XVThumbImagePlugin
from .helper import assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import BdfFontFile, FontFile
filename = "Tests/images/courB08.bdf"

View File

@ -1,6 +1,7 @@
import os
import pytest
from PIL import FontFile, Image, ImageDraw, ImageFont, PcfFontFile
from .helper import assert_image_equal, assert_image_similar, skip_unless_feature

View File

@ -3,8 +3,9 @@ import os
import shutil
import tempfile
import PIL
import pytest
import PIL
from PIL import Image, ImageDraw, ImagePalette, ImageShow, UnidentifiedImageError
from .helper import (
@ -466,18 +467,6 @@ class TestImage:
with pytest.raises(ValueError):
Image.core.fill("RGB", (2, -2), (0, 0, 0))
def test_offset_not_implemented(self):
# Arrange
with hopper() as im:
# Act / Assert
with pytest.raises(NotImplementedError):
im.offset(None)
def test_fromstring(self):
with pytest.raises(NotImplementedError):
Image.fromstring()
def test_linear_gradient_wrong_mode(self):
# Arrange
wrong_mode = "RGB"

View File

@ -2,9 +2,11 @@ import ctypes
import os
import subprocess
import sys
from distutils import ccompiler, sysconfig
import sysconfig
import pytest
from setuptools.command.build_ext import new_compiler
from PIL import Image
from .helper import assert_image_equal, hopper, is_win32, on_ci
@ -15,8 +17,9 @@ if os.environ.get("PYTHONOPTIMIZE") == "2":
cffi = None
else:
try:
from PIL import PyAccess
import cffi
from PIL import PyAccess
except ImportError:
cffi = None
@ -359,13 +362,12 @@ int main(int argc, char* argv[])
% sys.prefix.replace("\\", "\\\\")
)
compiler = ccompiler.new_compiler()
compiler.add_include_dir(sysconfig.get_python_inc())
compiler = new_compiler()
compiler.add_include_dir(sysconfig.get_config_var("INCLUDEPY"))
libdir = sysconfig.get_config_var(
"LIBDIR"
) or sysconfig.get_python_inc().replace("include", "libs")
print(libdir)
libdir = sysconfig.get_config_var("LIBDIR") or sysconfig.get_config_var(
"INCLUDEPY"
).replace("include", "libs")
compiler.add_library_dir(libdir)
objects = compiler.compile(["embed_pil.c"])
compiler.link_executable(objects, "embed_pil")

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import assert_image, assert_image_equal, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import assert_image_equal, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageFilter
from .helper import assert_image_equal, hopper

View File

@ -1,4 +1,3 @@
import pytest
from PIL import Image
from .helper import assert_image_equal, hopper
@ -9,8 +8,3 @@ def test_sanity():
im2 = Image.frombytes(im1.mode, im1.size, im1.tobytes())
assert_image_equal(im1, im2)
def test_not_implemented():
with pytest.raises(NotImplementedError):
Image.fromstring()

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageQt
from .helper import assert_image_equal, hopper

View File

@ -1,6 +1,7 @@
import os
import pytest
from PIL import Image
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import ImagePalette
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import assert_image, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageMath, ImageMode
from .helper import convert_to_comparable, skip_unless_feature

View File

@ -1,6 +1,7 @@
from contextlib import contextmanager
import pytest
from PIL import Image, ImageDraw
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -4,6 +4,7 @@ Tests for resize functionality.
from itertools import permutations
import pytest
from PIL import Image
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image
from .helper import (

View File

@ -1,6 +1,7 @@
import math
import pytest
from PIL import Image, ImageTransform
from .helper import assert_image_equal, assert_image_similar, hopper

View File

@ -4,6 +4,7 @@ import re
from io import BytesIO
import pytest
from PIL import Image, ImageMode, features
from .helper import assert_image, assert_image_equal, assert_image_similar, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageColor

View File

@ -1,6 +1,7 @@
import os.path
import pytest
from PIL import Image, ImageColor, ImageDraw, ImageFont
from .helper import (

View File

@ -1,6 +1,7 @@
from io import BytesIO
import pytest
from PIL import EpsImagePlugin, Image, ImageFile, features
from .helper import (

View File

@ -7,6 +7,7 @@ from io import BytesIO
import pytest
from packaging.version import parse as parse_version
from PIL import Image, ImageDraw, ImageFont, features
from .helper import (

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageDraw, ImageFont
from .helper import assert_image_similar

View File

@ -1,4 +1,5 @@
import pytest
from packaging.version import parse as parse_version
from PIL import Image, ImageDraw, ImageFont, features

View File

@ -3,6 +3,7 @@ import subprocess
import sys
import pytest
from PIL import Image, ImageGrab
from .helper import assert_image, assert_image_equal_tofile, skip_unless_feature

View File

@ -1,5 +1,6 @@
# Test the ImageMorphology functionality
import pytest
from PIL import Image, ImageMorph, _imagingmorph
from .helper import assert_image_equal, hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageOps, features
from .helper import (

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageFilter

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImagePalette
from .helper import assert_image_equal

View File

@ -2,6 +2,7 @@ import array
import struct
import pytest
from PIL import Image, ImagePath

View File

@ -1,4 +1,5 @@
import pytest
from PIL import ImageQt
from .helper import hopper

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageSequence, TiffImagePlugin
from .helper import assert_image_equal, hopper, skip_unless_feature

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageShow
from .helper import hopper, is_win32, on_ci

View File

@ -1,4 +1,5 @@
import pytest
from PIL import Image, ImageStat
from .helper import hopper

View File

@ -1,13 +1,14 @@
import pytest
from PIL import Image
from .helper import assert_image_equal, hopper
try:
from PIL import ImageTk
import tkinter as tk
from PIL import ImageTk
dir(ImageTk)
HAS_TK = True
except (OSError, ImportError):

Some files were not shown because too many files have changed in this diff Show More