From dc2201597363b262a0bf3f84a9132a21e254ee99 Mon Sep 17 00:00:00 2001 From: nulano Date: Sat, 27 Jun 2020 20:12:10 +0200 Subject: [PATCH 01/23] add gitignore to winbuild build directory --- winbuild/build_prepare.py | 1 + 1 file changed, 1 insertion(+) diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 553ed6365..55ea94ebf 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -553,5 +553,6 @@ if __name__ == "__main__": print() + write_script(".gitignore", ["*"]) build_dep_all() build_pillow() From 40aefc6ba5a060d9ec06bc9dbdacbdb87c80d2a7 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 17 Jul 2020 10:55:20 +0300 Subject: [PATCH 02/23] Remove im.offset, deprecated in 2001; and fromstring and tostring, deprecated in 2013 --- Tests/test_image.py | 12 ------------ Tests/test_image_frombytes.py | 6 ------ docs/deprecations.rst | 27 +++++++++++++++++++++++++++ docs/reference/Image.rst | 4 ---- src/PIL/Image.py | 21 --------------------- 5 files changed, 27 insertions(+), 43 deletions(-) diff --git a/Tests/test_image.py b/Tests/test_image.py index 6d29ac80e..068fb8172 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -466,18 +466,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" diff --git a/Tests/test_image_frombytes.py b/Tests/test_image_frombytes.py index faf94ac77..7fb05cda7 100644 --- a/Tests/test_image_frombytes.py +++ b/Tests/test_image_frombytes.py @@ -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() diff --git a/docs/deprecations.rst b/docs/deprecations.rst index b5ba00e40..f51961f1b 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -55,6 +55,33 @@ Removed features Deprecated features are only removed in major releases after an appropriate period of deprecation has passed. +im.offset +~~~~~~~~~ + +.. deprecated:: 1.1.2 +.. versionremoved:: 8.0.0 + +``im.offset()`` has been removed, call ``ImageChops.offset()`` instead. + +It was documented as deprecated in PIL 1.1.2, +raised a ``DeprecationWarning`` since 1.1.5, +an ``Exception`` since Pillow 3.0.0 +and ``NotImplementedError`` since 3.3.0. + +im.fromstring and tostring +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 2.0.0 +.. versionremoved:: 8.0.0 + +* ``Image.fromstring()`` has been removed, call ``frombytes()`` instead. +* ``im.fromstring()`` has been removed, call ``frombytes()`` instead. +* ``im.tostring()`` has been removed, call ``tobytes()`` instead. + +They issued a ``DeprecationWarning`` since 2.0.0, +an ``Exception`` since 3.0.0 +and ``NotImplementedError`` since 3.3.0. + ImageCms.CmsProfile attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index f24d382b8..d49bd7e62 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -196,7 +196,6 @@ This helps to get the bounding box coordinates of the input image: .. automethod:: PIL.Image.Image.getpixel .. automethod:: PIL.Image.Image.getprojection .. automethod:: PIL.Image.Image.histogram -.. automethod:: PIL.Image.Image.offset .. automethod:: PIL.Image.Image.paste .. automethod:: PIL.Image.Image.point .. automethod:: PIL.Image.Image.putalpha @@ -243,7 +242,6 @@ This rotates the input image by ``theta`` degrees counter clockwise: .. automethod:: PIL.Image.Image.thumbnail .. automethod:: PIL.Image.Image.tobitmap .. automethod:: PIL.Image.Image.tobytes -.. automethod:: PIL.Image.Image.tostring .. automethod:: PIL.Image.Image.transform .. automethod:: PIL.Image.Image.transpose @@ -263,8 +261,6 @@ This flips the input image by using the :data:`FLIP_LEFT_RIGHT` method. .. automethod:: PIL.Image.Image.verify -.. automethod:: PIL.Image.Image.fromstring - .. automethod:: PIL.Image.Image.load .. automethod:: PIL.Image.Image.close diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 03829d9a9..f4361b248 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -746,11 +746,6 @@ class Image: return b"".join(data) - def tostring(self, *args, **kw): - raise NotImplementedError( - "tostring() has been removed. Please call tobytes() instead." - ) - def tobitmap(self, name="image"): """ Returns the image converted to an X11 bitmap. @@ -802,11 +797,6 @@ class Image: if s[1] != 0: raise ValueError("cannot decode image data") - def fromstring(self, *args, **kw): - raise NotImplementedError( - "fromstring() has been removed. Please call frombytes() instead." - ) - def load(self): """ Allocates storage for the image and loads the pixel data. In @@ -1434,11 +1424,6 @@ class Image: return self.im.entropy(extrema) return self.im.entropy() - def offset(self, xoffset, yoffset=None): - raise NotImplementedError( - "offset() has been removed. Please call ImageChops.offset() instead." - ) - def paste(self, im, box=None, mask=None): """ Pastes another image into this image. The box argument is either @@ -2672,12 +2657,6 @@ def frombytes(mode, size, data, decoder_name="raw", *args): return im -def fromstring(*args, **kw): - raise NotImplementedError( - "fromstring() has been removed. Please call frombytes() instead." - ) - - def frombuffer(mode, size, data, decoder_name="raw", *args): """ Creates an image memory referencing pixel data in a byte buffer. From 39bc25e28ac9da12e2fef3a741e22c6f37e50033 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 18 Jul 2020 10:09:15 +0300 Subject: [PATCH 03/23] Link to the replacement functions Co-authored-by: nulano --- docs/deprecations.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/deprecations.rst b/docs/deprecations.rst index f51961f1b..bd8384996 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -74,9 +74,9 @@ im.fromstring and tostring .. deprecated:: 2.0.0 .. versionremoved:: 8.0.0 -* ``Image.fromstring()`` has been removed, call ``frombytes()`` instead. -* ``im.fromstring()`` has been removed, call ``frombytes()`` instead. -* ``im.tostring()`` has been removed, call ``tobytes()`` instead. +* ``Image.fromstring()`` has been removed, call :py:func:`.Image.frombytes()` instead. +* ``im.fromstring()`` has been removed, call :py:meth:`~PIL.Image.Image.frombytes()` instead. +* ``im.tostring()`` has been removed, call :py:meth:`~PIL.Image.Image.tobytes()` instead. They issued a ``DeprecationWarning`` since 2.0.0, an ``Exception`` since 3.0.0 From 415a4aa8ac9e91d3b66f7ae094f5bda262281cb8 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 18 Jul 2020 10:13:18 +0300 Subject: [PATCH 04/23] Add PIL.Image.Image.frombytes to docs --- docs/reference/Image.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index d49bd7e62..cd0bffc8b 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -151,6 +151,7 @@ This crops the input image with the provided coordinates: .. automethod:: PIL.Image.Image.draft .. automethod:: PIL.Image.Image.effect_spread .. automethod:: PIL.Image.Image.entropy +.. automethod:: PIL.Image.Image.frombytes .. automethod:: PIL.Image.Image.filter This blurs the input image using a filter from the ``ImageFilter`` module: From 307239b23435587007070b3a6179e4100d85158a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 21 Jul 2020 11:23:38 +0300 Subject: [PATCH 05/23] Replace distutils.sysconfig.get_config_var("prefix") with os.path.normpath(sys.prefix) --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 59f6d2970..0b8abaf80 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ import struct import subprocess import sys import warnings -from distutils import ccompiler, sysconfig +from distutils import ccompiler from distutils.command.build_ext import build_ext from setuptools import Extension, setup @@ -418,7 +418,7 @@ class pil_build_ext(build_ext): for d in os.environ[k].split(os.path.pathsep): _add_directory(library_dirs, d) - prefix = sysconfig.get_config_var("prefix") + prefix = os.path.normpath(sys.prefix) if prefix: _add_directory(library_dirs, os.path.join(prefix, "lib")) _add_directory(include_dirs, os.path.join(prefix, "include")) From b8ccd97d756efa0f0a328fe354e0f4dd4ec261a3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 21 Jul 2020 15:55:32 +0300 Subject: [PATCH 06/23] Update title Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- docs/deprecations.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/deprecations.rst b/docs/deprecations.rst index bd8384996..10ccec632 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -68,8 +68,8 @@ raised a ``DeprecationWarning`` since 1.1.5, an ``Exception`` since Pillow 3.0.0 and ``NotImplementedError`` since 3.3.0. -im.fromstring and tostring -~~~~~~~~~~~~~~~~~~~~~~~~~~ +Image.fromstring, im.fromstring and im.tostring +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. deprecated:: 2.0.0 .. versionremoved:: 8.0.0 From ea96cbeddc050433cead4cac063a6ca47063af55 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 22 Jul 2020 12:10:23 +0300 Subject: [PATCH 07/23] Alphabetise Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- docs/reference/Image.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index cd0bffc8b..bd18a4dc4 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -151,8 +151,8 @@ This crops the input image with the provided coordinates: .. automethod:: PIL.Image.Image.draft .. automethod:: PIL.Image.Image.effect_spread .. automethod:: PIL.Image.Image.entropy -.. automethod:: PIL.Image.Image.frombytes .. automethod:: PIL.Image.Image.filter +.. automethod:: PIL.Image.Image.frombytes This blurs the input image using a filter from the ``ImageFilter`` module: From 836dcc5ba06cde8eba64d35b2641a32b6b1508cc Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 23 Jul 2020 22:40:02 +1000 Subject: [PATCH 08/23] Document missing attributes --- docs/conf.py | 7 +------ docs/handbook/image-file-formats.rst | 14 +++++++------- src/PIL/ImageFile.py | 2 ++ src/PIL/TiffImagePlugin.py | 16 +++++++++++++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 5b42bba11..caddae327 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -114,12 +114,7 @@ nitpicky = True # generating warnings in “nitpicky mode”. Note that type should include the domain name # if present. Example entries would be ('py:func', 'int') or # ('envvar', 'LD_LIBRARY_PATH'). -nitpick_ignore = [ - ("py:attr", "PIL.Image.Image.tag"), - ("py:attr", "PIL.Image.Image.tag_v2"), - ("py:attr", "PIL.Image.Image.tile"), - ("py:attr", "PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype"), -] +# nitpick_ignore = [] # -- Options for HTML output ---------------------------------------------- diff --git a/docs/handbook/image-file-formats.rst b/docs/handbook/image-file-formats.rst index bd565f79c..89e3dfd4a 100644 --- a/docs/handbook/image-file-formats.rst +++ b/docs/handbook/image-file-formats.rst @@ -186,7 +186,7 @@ Reading local images The GIF loader creates an image memory the same size as the GIF file’s *logical screen size*, and pastes the actual pixel data (the *local image*) into this image. If you only want the actual pixel rectangle, you can manipulate the -:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.Image.Image.tile` +:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.ImageFile.ImageFile.tile` attributes before loading the file:: im = Image.open(...) @@ -764,8 +764,8 @@ The :py:meth:`~PIL.Image.open` method sets the following **dpi** Image resolution as an ``(xdpi, ydpi)`` tuple, where applicable. You can use - the :py:attr:`~PIL.Image.Image.tag` attribute to get more detailed - information about the image resolution. + the :py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag` attribute to get more + detailed information about the image resolution. .. versionadded:: 1.1.5 @@ -776,8 +776,8 @@ The :py:meth:`~PIL.Image.open` method sets the following .. versionadded:: 1.1.5 -The :py:attr:`~PIL.Image.Image.tag_v2` attribute contains a dictionary -of TIFF metadata. The keys are numerical indexes from +The :py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag_v2` attribute contains a +dictionary of TIFF metadata. The keys are numerical indexes from :py:data:`.TiffTags.TAGS_V2`. Values are strings or numbers for single items, multiple values are returned in a tuple of values. Rational numbers are returned as a :py:class:`~PIL.TiffImagePlugin.IFDRational` @@ -786,8 +786,8 @@ object. .. versionadded:: 3.0.0 For compatibility with legacy code, the -:py:attr:`~PIL.Image.Image.tag` attribute contains a dictionary of -decoded TIFF fields as returned prior to version 3.0.0. Values are +:py:attr:`~PIL.TiffImagePlugin.TiffImageFile.tag` attribute contains a dictionary +of decoded TIFF fields as returned prior to version 3.0.0. Values are returned as either strings or tuples of numeric values. Rational numbers are returned as a tuple of ``(numerator, denominator)``. diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index fd2e1bbde..648101ee3 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -95,6 +95,8 @@ class ImageFile(Image.Image): self.custom_mimetype = None self.tile = None + """ A list of tile descriptors, or ``None`` """ + self.readonly = 1 # until we know better self.decoderconfig = () diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index b56072737..012d25302 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -472,6 +472,8 @@ class ImageFileDirectory_v2(MutableMapping): self._endian = "<" else: raise SyntaxError("not a TIFF IFD") + self.tagtype = {} + """ Dictionary of tag types """ self.reset() (self.next,) = self._unpack("L", ifh[4:]) self._legacy_api = False @@ -972,17 +974,25 @@ class TiffImageFile(ImageFile.ImageFile): format_description = "Adobe TIFF" _close_exclusive_fp_after_loading = False + def __init__(self, fp=None, filename=None): + self.tag_v2 = None + """ Image file directory (tag dictionary) """ + + self.tag = None + """ Legacy tag entries """ + + super().__init__(fp, filename) + def _open(self): """Open the first image in a TIFF file""" # Header ifh = self.fp.read(8) - # image file directory (tag dictionary) self.tag_v2 = ImageFileDirectory_v2(ifh) - # legacy tag/ifd entries will be filled in later - self.tag = self.ifd = None + # legacy ifd entries will be filled in later + self.ifd = None # setup frame pointers self.__first = self.__next = self.tag_v2.next From 908567a7187c2209e5b0a643f5ebe7f73b0a6e5e Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Fri, 24 Jul 2020 01:04:19 +1000 Subject: [PATCH 09/23] Capitalisaton Co-authored-by: Hugo van Kemenade --- src/PIL/TiffImagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 012d25302..6a772e48b 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -991,7 +991,7 @@ class TiffImageFile(ImageFile.ImageFile): self.tag_v2 = ImageFileDirectory_v2(ifh) - # legacy ifd entries will be filled in later + # legacy IFD entries will be filled in later self.ifd = None # setup frame pointers From 7c576adb19e08511ce4ba461160acb1e52a77329 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 24 Jul 2020 19:58:17 +1000 Subject: [PATCH 10/23] Simplified code --- setup.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 0b8abaf80..f8b9f4a81 100755 --- a/setup.py +++ b/setup.py @@ -418,10 +418,8 @@ class pil_build_ext(build_ext): for d in os.environ[k].split(os.path.pathsep): _add_directory(library_dirs, d) - prefix = os.path.normpath(sys.prefix) - if prefix: - _add_directory(library_dirs, os.path.join(prefix, "lib")) - _add_directory(include_dirs, os.path.join(prefix, "include")) + _add_directory(library_dirs, os.path.join(sys.prefix, "lib")) + _add_directory(include_dirs, os.path.join(sys.prefix, "include")) # # add platform directories From 99a2aa0e711e20bf443c3113a15d090521ab1900 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 24 Jul 2020 20:49:43 +1000 Subject: [PATCH 11/23] Updated CHANGES.rst [ci skip] --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d5d1330c2..6083cc7f3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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] From 42bb401e883dabc2c2299b8cff995b5cc3ae8aa5 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 25 Jul 2020 20:03:27 +1000 Subject: [PATCH 12/23] Replaced distutils sysconfig --- Tests/test_image_access.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index 25cc9fef4..9a3af9e53 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -2,7 +2,8 @@ import ctypes import os import subprocess import sys -from distutils import ccompiler, sysconfig +import sysconfig +from distutils import ccompiler import pytest from PIL import Image @@ -360,12 +361,11 @@ int main(int argc, char* argv[]) ) compiler = ccompiler.new_compiler() - compiler.add_include_dir(sysconfig.get_python_inc()) + 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") From 86828b3fa672873f69c33011b5b50a680d4a452f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 25 Jul 2020 21:05:31 +1000 Subject: [PATCH 13/23] Updated harfbuzz to 2.7.0 --- winbuild/build_prepare.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 6f9cf4038..7edc7df5b 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -251,9 +251,9 @@ deps = { "libs": [r"*.lib"], }, "harfbuzz": { - "url": "https://github.com/harfbuzz/harfbuzz/archive/2.6.8.zip", - "filename": "harfbuzz-2.6.8.zip", - "dir": "harfbuzz-2.6.8", + "url": "https://github.com/harfbuzz/harfbuzz/archive/2.7.0.zip", + "filename": "harfbuzz-2.7.0.zip", + "dir": "harfbuzz-2.7.0", "build": [ cmd_cmake("-DHB_HAVE_FREETYPE:BOOL=TRUE"), cmd_nmake(target="clean"), From a10634e13f1f7587028dd057d763f0d272442817 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 26 Jul 2020 14:59:30 +1000 Subject: [PATCH 14/23] Do not explicitly import distutils --- Tests/test_image_access.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index 9a3af9e53..57612c4b0 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -3,7 +3,8 @@ import os import subprocess import sys import sysconfig -from distutils import ccompiler + +from setuptools.command.build_ext import new_compiler import pytest from PIL import Image @@ -360,7 +361,7 @@ int main(int argc, char* argv[]) % sys.prefix.replace("\\", "\\\\") ) - compiler = ccompiler.new_compiler() + compiler = new_compiler() compiler.add_include_dir(sysconfig.get_config_var("INCLUDEPY")) libdir = sysconfig.get_config_var("LIBDIR") or sysconfig.get_config_var( From 73f51ae484f980d785eb59483087ae24adebd376 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 26 Jul 2020 21:01:25 +1000 Subject: [PATCH 15/23] Removed distutils from MinGW detection --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f8b9f4a81..d654e4d41 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,6 @@ import struct import subprocess import sys import warnings -from distutils import ccompiler from distutils.command.build_ext import build_ext from setuptools import Extension, setup @@ -131,7 +130,7 @@ class RequiredDependencyException(Exception): pass -PLATFORM_MINGW = "mingw" in ccompiler.get_default_compiler() +PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version PLATFORM_PYPY = hasattr(sys, "pypy_version_info") if sys.platform == "win32" and PLATFORM_MINGW: From fda22ed82e070077502bc4e184d383e219edbabf Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 29 Jul 2020 07:54:33 +1000 Subject: [PATCH 16/23] Removed unused variables --- Tests/test_file_libtiff.py | 3 --- Tests/test_file_tiff.py | 3 --- 2 files changed, 6 deletions(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 300967a30..22b048fc2 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -1,7 +1,6 @@ import base64 import io import itertools -import logging import os import re from collections import namedtuple @@ -19,8 +18,6 @@ from .helper import ( skip_unless_feature, ) -logger = logging.getLogger(__name__) - @skip_unless_feature("libtiff") class LibTiffTestCase: diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 7aa55dad0..cf22d647c 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -1,4 +1,3 @@ -import logging import os from io import BytesIO @@ -16,8 +15,6 @@ from .helper import ( is_win32, ) -logger = logging.getLogger(__name__) - class TestFileTiff: def test_sanity(self, tmp_path): From 446a836f1c49461c97b35aaa39ada5a18827d36d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 29 Jul 2020 19:24:50 +0300 Subject: [PATCH 17/23] Remove outdated make upload-test and upload commands, we use twine now --- Makefile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Makefile b/Makefile index 06208ad98..b4375db3d 100644 --- a/Makefile +++ b/Makefile @@ -90,16 +90,5 @@ sdist: 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 - readme: viewdoc From 43fca3dcd30fe8adc4848c6c5cd82b5631b0a7f2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 31 Jul 2020 19:14:43 +1000 Subject: [PATCH 18/23] Replaced distutils build_ext with setuptools --- setup.py | 85 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/setup.py b/setup.py index d654e4d41..cc2768431 100755 --- a/setup.py +++ b/setup.py @@ -14,9 +14,9 @@ import struct import subprocess import sys import warnings -from distutils.command.build_ext import build_ext from setuptools import Extension, setup +from setuptools.command.build_ext import build_ext def get_version(): @@ -351,6 +351,22 @@ class pil_build_ext(build_ext): _dbg("Requiring %s", x) self.feature.required.add(x) + def _update_extension(self, name, libraries, define_macros=None, include_dirs=None): + for extension in self.extensions: + if extension.name == name: + extension.libraries += libraries + if define_macros is not None: + extension.define_macros += define_macros + if include_dirs is not None: + extension.include_dirs += include_dirs + break + + def _remove_extension(self, name): + for extension in self.extensions: + if extension.name == name: + self.extensions.remove(extension) + break + def build_extensions(self): library_dirs = [] @@ -694,12 +710,6 @@ class pil_build_ext(build_ext): # # core library - files = ["src/_imaging.c"] - for src_file in _IMAGING: - files.append("src/" + src_file + ".c") - for src_file in _LIB_IMAGING: - files.append(os.path.join("src/libImaging", src_file + ".c")) - libs = self.add_imaging_libs.split() defs = [] if feature.jpeg: @@ -736,7 +746,7 @@ class pil_build_ext(build_ext): else: defs.append(("PILLOW_VERSION", '"%s"' % PILLOW_VERSION)) - exts = [(Extension("PIL._imaging", files, libraries=libs, define_macros=defs))] + self._update_extension("PIL._imaging", libs, defs) # # additional libraries @@ -744,26 +754,17 @@ class pil_build_ext(build_ext): if feature.freetype: libs = ["freetype"] defs = [] - exts.append( - Extension( - "PIL._imagingft", - ["src/_imagingft.c"], - libraries=libs, - define_macros=defs, - ) - ) + self._update_extension("PIL._imagingft", libs, defs) + else: + self._remove_extension("PIL._imagingft") if feature.lcms: extra = [] if sys.platform == "win32": extra.extend(["user32", "gdi32"]) - exts.append( - Extension( - "PIL._imagingcms", - ["src/_imagingcms.c"], - libraries=[feature.lcms] + extra, - ) - ) + self._update_extension("PIL._imagingcms", [feature.lcms] + extra) + else: + self._remove_extension("PIL._imagingcms") if feature.webp: libs = [feature.webp] @@ -774,26 +775,12 @@ class pil_build_ext(build_ext): libs.append(feature.webpmux) libs.append(feature.webpmux.replace("pmux", "pdemux")) - exts.append( - Extension( - "PIL._webp", ["src/_webp.c"], libraries=libs, define_macros=defs - ) - ) + self._update_extension("PIL._webp", libs, defs) + else: + self._remove_extension("PIL._webp") tk_libs = ["psapi"] if sys.platform == "win32" else [] - exts.append( - Extension( - "PIL._imagingtk", - ["src/_imagingtk.c", "src/Tk/tkImaging.c"], - include_dirs=["src/Tk"], - libraries=tk_libs, - ) - ) - - exts.append(Extension("PIL._imagingmath", ["src/_imagingmath.c"])) - exts.append(Extension("PIL._imagingmorph", ["src/_imagingmorph.c"])) - - self.extensions[:] = exts + self._update_extension("PIL._imagingtk", tk_libs, include_dirs=["src/Tk"]) build_ext.build_extensions(self) @@ -857,6 +844,20 @@ def debug_build(): return hasattr(sys, "gettotalrefcount") +files = ["src/_imaging.c"] +for src_file in _IMAGING: + files.append("src/" + src_file + ".c") +for src_file in _LIB_IMAGING: + files.append(os.path.join("src/libImaging", src_file + ".c")) +ext_modules = [ + Extension("PIL._imaging", files), + Extension("PIL._imagingft", ["src/_imagingft.c"]), + Extension("PIL._imagingcms", ["src/_imagingcms.c"]), + Extension("PIL._webp", ["src/_webp.c"]), + Extension("PIL._imagingtk", ["src/_imagingtk.c", "src/Tk/tkImaging.c"]), + Extension("PIL._imagingmath", ["src/_imagingmath.c"]), + Extension("PIL._imagingmorph", ["src/_imagingmorph.c"]), +] try: setup( name=NAME, @@ -891,7 +892,7 @@ try: ], python_requires=">=3.6", cmdclass={"build_ext": pil_build_ext}, - ext_modules=[Extension("PIL._imaging", ["_imaging.c"])], + ext_modules=ext_modules, include_package_data=True, packages=["PIL"], package_dir={"": "src"}, From 96a125911abb3831d502f37a63de9098b9762718 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 1 Aug 2020 11:09:55 +1000 Subject: [PATCH 19/23] Updated phony targets --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b4375db3d..2eb2e95d0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # 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 +.PHONY: clean co coverage doc doccheck docserve help inplace install install-coverage debug install-req install-venv release-test sdist test readme .DEFAULT_GOAL := release-test clean: From a23ec9cfb766c81464dd7d52be7502a4c3d6109a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 1 Aug 2020 19:21:28 +1000 Subject: [PATCH 20/23] Split phony targets --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2eb2e95d0..cbee5923b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ -# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html -.PHONY: clean co coverage doc doccheck docserve help inplace install install-coverage debug install-req install-venv release-test sdist test readme .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 \` where 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,11 +96,14 @@ release-test: pyroma . viewdoc +.PHONY: sdist sdist: python3 setup.py sdist --format=gztar +.PHONY: test test: pytest -qq +.PHONY: readme readme: viewdoc From e02af3e58b33ec736a7b241c58682138466e14fc Mon Sep 17 00:00:00 2001 From: nulano Date: Sun, 2 Aug 2020 22:15:59 +0200 Subject: [PATCH 21/23] delete obsolete files for AppVeyor --- winbuild/appveyor_build_msys2.sh | 3 --- winbuild/appveyor_install_msys2_deps.sh | 14 -------------- 2 files changed, 17 deletions(-) delete mode 100644 winbuild/appveyor_build_msys2.sh delete mode 100644 winbuild/appveyor_install_msys2_deps.sh diff --git a/winbuild/appveyor_build_msys2.sh b/winbuild/appveyor_build_msys2.sh deleted file mode 100644 index 489f9411e..000000000 --- a/winbuild/appveyor_build_msys2.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -cd /c/pillow && /mingw32/$EXECUTABLE setup.py install diff --git a/winbuild/appveyor_install_msys2_deps.sh b/winbuild/appveyor_install_msys2_deps.sh deleted file mode 100644 index 4cc01082d..000000000 --- a/winbuild/appveyor_install_msys2_deps.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -mkdir /var/cache/pacman/pkg -pacman -S --noconfirm mingw32/mingw-w64-i686-python3-pip \ - mingw32/mingw-w64-i686-python3-setuptools \ - mingw32/mingw-w64-i686-python3-pytest \ - mingw32/mingw-w64-i686-python3-pytest-cov \ - mingw-w64-i686-libjpeg-turbo \ - mingw-w64-i686-libimagequant - -C:/msys64/mingw32/bin/python3 -m pip install --upgrade pip - -/mingw32/bin/pip install olefile -/mingw32/bin/pip3 install olefile From dece040ee84e3854815e6443e02241781a894f7f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 7 Aug 2020 09:19:15 +0300 Subject: [PATCH 22/23] Fix RST backticks --- .pre-commit-config.yaml | 10 +++++----- docs/reference/block_allocator.rst | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a37674036..0e032f8a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,30 +14,30 @@ repos: - 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 diff --git a/docs/reference/block_allocator.rst b/docs/reference/block_allocator.rst index 400f236dc..1abe5280f 100644 --- a/docs/reference/block_allocator.rst +++ b/docs/reference/block_allocator.rst @@ -40,7 +40,7 @@ variables: * ``PILLOW_BLOCK_SIZE``, in bytes, K, or M. Specifies the maximum block size for ``ImagingAllocateArray``. Valid values are - integers, with an optional `k` or `m` suffix. Defaults to 16M. + integers, with an optional ``k`` or ``m`` suffix. Defaults to 16M. * ``PILLOW_BLOCKS_MAX`` Specifies the number of freed blocks to retain to fill future memory requests. Any freed blocks over this From dd87dd50c0b5c09bffc12b9c8f39dd376fe5ac4d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 7 Aug 2020 13:28:33 +0300 Subject: [PATCH 23/23] Update to isort 5 with Black profile support --- .pre-commit-config.yaml | 2 +- Tests/check_imaging_leaks.py | 3 ++- Tests/check_j2k_leaks.py | 5 +++-- Tests/check_j2k_overflow.py | 1 + Tests/check_large_memory.py | 1 + Tests/check_large_memory_numpy.py | 1 + Tests/check_libtiff_segfault.py | 1 + Tests/helper.py | 3 ++- Tests/test_bmp_reference.py | 1 + Tests/test_box_blur.py | 1 + Tests/test_color_lut.py | 1 + Tests/test_core_resources.py | 1 + Tests/test_decompression_bomb.py | 1 + Tests/test_features.py | 1 + Tests/test_file_apng.py | 1 + Tests/test_file_bmp.py | 1 + Tests/test_file_bufrstub.py | 1 + Tests/test_file_cur.py | 1 + Tests/test_file_dcx.py | 1 + Tests/test_file_dds.py | 1 + Tests/test_file_eps.py | 1 + Tests/test_file_fitsstub.py | 1 + Tests/test_file_fli.py | 1 + Tests/test_file_fpx.py | 1 + Tests/test_file_gbr.py | 1 + Tests/test_file_gd.py | 1 + Tests/test_file_gif.py | 1 + Tests/test_file_gimppalette.py | 1 + Tests/test_file_gribstub.py | 1 + Tests/test_file_hdf5stub.py | 1 + Tests/test_file_icns.py | 1 + Tests/test_file_ico.py | 1 + Tests/test_file_im.py | 1 + Tests/test_file_jpeg.py | 1 + Tests/test_file_jpeg2k.py | 1 + Tests/test_file_libtiff.py | 1 + Tests/test_file_mcidas.py | 1 + Tests/test_file_mic.py | 1 + Tests/test_file_mpo.py | 1 + Tests/test_file_msp.py | 1 + Tests/test_file_palm.py | 1 + Tests/test_file_pcx.py | 1 + Tests/test_file_pdf.py | 1 + Tests/test_file_pixar.py | 1 + Tests/test_file_png.py | 1 + Tests/test_file_ppm.py | 1 + Tests/test_file_psd.py | 1 + Tests/test_file_sgi.py | 1 + Tests/test_file_spider.py | 1 + Tests/test_file_sun.py | 1 + Tests/test_file_tar.py | 1 + Tests/test_file_tga.py | 1 + Tests/test_file_tiff.py | 1 + Tests/test_file_tiff_metadata.py | 1 + Tests/test_file_webp.py | 1 + Tests/test_file_webp_alpha.py | 1 + Tests/test_file_webp_animated.py | 1 + Tests/test_file_webp_lossless.py | 1 + Tests/test_file_wmf.py | 1 + Tests/test_file_xbm.py | 1 + Tests/test_file_xpm.py | 1 + Tests/test_file_xvthumb.py | 1 + Tests/test_font_bdf.py | 1 + Tests/test_font_pcf.py | 1 + Tests/test_image.py | 3 ++- Tests/test_image_access.py | 5 +++-- Tests/test_image_array.py | 1 + Tests/test_image_convert.py | 1 + Tests/test_image_crop.py | 1 + Tests/test_image_filter.py | 1 + Tests/test_image_fromqimage.py | 1 + Tests/test_image_load.py | 1 + Tests/test_image_putpalette.py | 1 + Tests/test_image_quantize.py | 1 + Tests/test_image_reduce.py | 1 + Tests/test_image_resample.py | 1 + Tests/test_image_resize.py | 1 + Tests/test_image_thumbnail.py | 1 + Tests/test_image_transform.py | 1 + Tests/test_imagecms.py | 1 + Tests/test_imagecolor.py | 1 + Tests/test_imagedraw.py | 1 + Tests/test_imagefile.py | 1 + Tests/test_imagefont.py | 1 + Tests/test_imagefont_bitmap.py | 1 + Tests/test_imagefontctl.py | 1 + Tests/test_imagegrab.py | 1 + Tests/test_imagemorph.py | 1 + Tests/test_imageops.py | 1 + Tests/test_imageops_usm.py | 1 + Tests/test_imagepalette.py | 1 + Tests/test_imagepath.py | 1 + Tests/test_imageqt.py | 1 + Tests/test_imagesequence.py | 1 + Tests/test_imageshow.py | 1 + Tests/test_imagestat.py | 1 + Tests/test_imagetk.py | 5 +++-- Tests/test_imagewin.py | 1 + Tests/test_lib_image.py | 1 + Tests/test_lib_pack.py | 1 + Tests/test_locale.py | 1 + Tests/test_map.py | 1 + Tests/test_numpy.py | 1 + Tests/test_pdfparser.py | 1 + Tests/test_pickle.py | 1 + Tests/test_pyroma.py | 1 + Tests/test_qt_image_toqimage.py | 5 +++-- Tests/test_sgi_crash.py | 1 + Tests/test_shell_injection.py | 1 + Tests/test_util.py | 1 + docs/conf.py | 3 ++- setup.cfg | 5 +---- src/PIL/BmpImagePlugin.py | 7 ++++++- src/PIL/CurImagePlugin.py | 4 +++- src/PIL/FliImagePlugin.py | 5 ++++- src/PIL/FpxImagePlugin.py | 3 ++- src/PIL/GdImageFile.py | 4 +++- src/PIL/GifImagePlugin.py | 5 ++++- src/PIL/IcoImagePlugin.py | 4 +++- src/PIL/ImageDraw.py | 1 - src/PIL/ImageGrab.py | 2 +- src/PIL/ImageQt.py | 4 ++-- src/PIL/IptcImagePlugin.py | 8 ++++++-- src/PIL/JpegImagePlugin.py | 5 ++++- src/PIL/MspImagePlugin.py | 4 +++- src/PIL/PalmImagePlugin.py | 3 ++- src/PIL/PcfFontFile.py | 6 +++++- src/PIL/PcxImagePlugin.py | 5 ++++- src/PIL/PngImagePlugin.py | 7 ++++++- src/PIL/PsdImagePlugin.py | 4 +++- src/PIL/SgiImagePlugin.py | 4 +++- src/PIL/TgaImagePlugin.py | 5 ++++- src/PIL/WmfImagePlugin.py | 5 ++++- winbuild/build_prepare.py | 2 +- 134 files changed, 197 insertions(+), 41 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e032f8a5..d619523d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: types: [] - repo: https://github.com/timothycrosley/isort - rev: 7c29dd9d55161704cfc45998c6f5c2c43d39264b # frozen: 4.3.21 + rev: 9ae09866e278fbc6ec0383ccb16b5c84e78e6e4d # frozen: 5.3.2 hooks: - id: isort diff --git a/Tests/check_imaging_leaks.py b/Tests/check_imaging_leaks.py index db12d00e3..e593b703a 100755 --- a/Tests/check_imaging_leaks.py +++ b/Tests/check_imaging_leaks.py @@ -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 diff --git a/Tests/check_j2k_leaks.py b/Tests/check_j2k_leaks.py index 5cef4b544..afe5836f3 100755 --- a/Tests/check_j2k_leaks.py +++ b/Tests/check_j2k_leaks.py @@ -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)) diff --git a/Tests/check_j2k_overflow.py b/Tests/check_j2k_overflow.py index 7a0a5f948..b16412898 100644 --- a/Tests/check_j2k_overflow.py +++ b/Tests/check_j2k_overflow.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image diff --git a/Tests/check_large_memory.py b/Tests/check_large_memory.py index f44a5a5bb..723a1a21e 100644 --- a/Tests/check_large_memory.py +++ b/Tests/check_large_memory.py @@ -1,6 +1,7 @@ import sys import pytest + from PIL import Image # This test is not run automatically. diff --git a/Tests/check_large_memory_numpy.py b/Tests/check_large_memory_numpy.py index de6f4571c..79d1cfd5b 100644 --- a/Tests/check_large_memory_numpy.py +++ b/Tests/check_large_memory_numpy.py @@ -1,6 +1,7 @@ import sys import pytest + from PIL import Image # This test is not run automatically. diff --git a/Tests/check_libtiff_segfault.py b/Tests/check_libtiff_segfault.py index 6663ac097..5a6116f4f 100644 --- a/Tests/check_libtiff_segfault.py +++ b/Tests/check_libtiff_segfault.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image TEST_FILE = "Tests/images/libtiff_segfault.tif" diff --git a/Tests/helper.py b/Tests/helper.py index cdc5f4efe..57bfab264 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -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": diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index ade2901b7..496eb697e 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -1,6 +1,7 @@ import os import pytest + from PIL import Image from .helper import assert_image_similar diff --git a/Tests/test_box_blur.py b/Tests/test_box_blur.py index 44910b9ed..94f504e0b 100644 --- a/Tests/test_box_blur.py +++ b/Tests/test_box_blur.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageFilter sample = Image.new("L", (7, 5)) diff --git a/Tests/test_color_lut.py b/Tests/test_color_lut.py index b34dbadb6..99776ce58 100644 --- a/Tests/test_color_lut.py +++ b/Tests/test_color_lut.py @@ -1,6 +1,7 @@ from array import array import pytest + from PIL import Image, ImageFilter from .helper import assert_image_equal diff --git a/Tests/test_core_resources.py b/Tests/test_core_resources.py index a8fe8bfeb..6c52d25a4 100644 --- a/Tests/test_core_resources.py +++ b/Tests/test_core_resources.py @@ -1,6 +1,7 @@ import sys import pytest + from PIL import Image from .helper import is_pypy diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py index 1704400b4..5799fc0ed 100644 --- a/Tests/test_decompression_bomb.py +++ b/Tests/test_decompression_bomb.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import hopper diff --git a/Tests/test_features.py b/Tests/test_features.py index 1e7692204..284f72205 100644 --- a/Tests/test_features.py +++ b/Tests/test_features.py @@ -2,6 +2,7 @@ import io import re import pytest + from PIL import features from .helper import skip_unless_feature diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py index 0eca78690..433807083 100644 --- a/Tests/test_file_apng.py +++ b/Tests/test_file_apng.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageSequence, PngImagePlugin diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index 8bb58794c..e2381df1e 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -1,6 +1,7 @@ import io import pytest + from PIL import BmpImagePlugin, Image from .helper import assert_image_equal, hopper diff --git a/Tests/test_file_bufrstub.py b/Tests/test_file_bufrstub.py index 6803a1230..11acc1c88 100644 --- a/Tests/test_file_bufrstub.py +++ b/Tests/test_file_bufrstub.py @@ -1,4 +1,5 @@ import pytest + from PIL import BufrStubImagePlugin, Image from .helper import hopper diff --git a/Tests/test_file_cur.py b/Tests/test_file_cur.py index 3200fd8f6..f04a20a22 100644 --- a/Tests/test_file_cur.py +++ b/Tests/test_file_cur.py @@ -1,4 +1,5 @@ import pytest + from PIL import CurImagePlugin, Image TEST_FILE = "Tests/images/deerstalker.cur" diff --git a/Tests/test_file_dcx.py b/Tests/test_file_dcx.py index bc76b4591..818d6ed5e 100644 --- a/Tests/test_file_dcx.py +++ b/Tests/test_file_dcx.py @@ -1,4 +1,5 @@ import pytest + from PIL import DcxImagePlugin, Image from .helper import assert_image_equal, hopper, is_pypy diff --git a/Tests/test_file_dds.py b/Tests/test_file_dds.py index 8960edea3..0aec9ea37 100644 --- a/Tests/test_file_dds.py +++ b/Tests/test_file_dds.py @@ -2,6 +2,7 @@ from io import BytesIO import pytest + from PIL import DdsImagePlugin, Image from .helper import assert_image_equal diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 504c09db1..f585a0669 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -1,6 +1,7 @@ import io import pytest + from PIL import EpsImagePlugin, Image, features from .helper import assert_image_similar, hopper, skip_unless_feature diff --git a/Tests/test_file_fitsstub.py b/Tests/test_file_fitsstub.py index 01bc2deee..6dc7c4602 100644 --- a/Tests/test_file_fitsstub.py +++ b/Tests/test_file_fitsstub.py @@ -1,4 +1,5 @@ import pytest + from PIL import FitsStubImagePlugin, Image TEST_FILE = "Tests/images/hopper.fits" diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index 726e16c1a..16b3dc59a 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -1,4 +1,5 @@ import pytest + from PIL import FliImagePlugin, Image from .helper import assert_image_equal, is_pypy diff --git a/Tests/test_file_fpx.py b/Tests/test_file_fpx.py index a247de79c..c3cc37ddf 100644 --- a/Tests/test_file_fpx.py +++ b/Tests/test_file_fpx.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image FpxImagePlugin = pytest.importorskip( diff --git a/Tests/test_file_gbr.py b/Tests/test_file_gbr.py index b95970889..760f12e4d 100644 --- a/Tests/test_file_gbr.py +++ b/Tests/test_file_gbr.py @@ -1,4 +1,5 @@ import pytest + from PIL import GbrImagePlugin, Image from .helper import assert_image_equal diff --git a/Tests/test_file_gd.py b/Tests/test_file_gd.py index b6f8594be..5594e5bbb 100644 --- a/Tests/test_file_gd.py +++ b/Tests/test_file_gd.py @@ -1,4 +1,5 @@ import pytest + from PIL import GdImageFile, UnidentifiedImageError TEST_GD_FILE = "Tests/images/hopper.gd" diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 455e30f71..90943ac8f 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -1,6 +1,7 @@ from io import BytesIO import pytest + from PIL import GifImagePlugin, Image, ImageDraw, ImagePalette, features from .helper import ( diff --git a/Tests/test_file_gimppalette.py b/Tests/test_file_gimppalette.py index a38c6320c..caec9cf21 100644 --- a/Tests/test_file_gimppalette.py +++ b/Tests/test_file_gimppalette.py @@ -1,4 +1,5 @@ import pytest + from PIL.GimpPaletteFile import GimpPaletteFile diff --git a/Tests/test_file_gribstub.py b/Tests/test_file_gribstub.py index 9d9def96b..e4930d8dc 100644 --- a/Tests/test_file_gribstub.py +++ b/Tests/test_file_gribstub.py @@ -1,4 +1,5 @@ import pytest + from PIL import GribStubImagePlugin, Image from .helper import hopper diff --git a/Tests/test_file_hdf5stub.py b/Tests/test_file_hdf5stub.py index 862cafa91..ff3397055 100644 --- a/Tests/test_file_hdf5stub.py +++ b/Tests/test_file_hdf5stub.py @@ -1,4 +1,5 @@ import pytest + from PIL import Hdf5StubImagePlugin, Image TEST_FILE = "Tests/images/hdf5.h5" diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py index 05feedb1a..a3d502d42 100644 --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -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 diff --git a/Tests/test_file_ico.py b/Tests/test_file_ico.py index 9ed1ffcb7..f7a513509 100644 --- a/Tests/test_file_ico.py +++ b/Tests/test_file_ico.py @@ -1,6 +1,7 @@ import io import pytest + from PIL import IcoImagePlugin, Image, ImageDraw from .helper import assert_image_equal, hopper diff --git a/Tests/test_file_im.py b/Tests/test_file_im.py index 30a9fd52a..afea82359 100644 --- a/Tests/test_file_im.py +++ b/Tests/test_file_im.py @@ -1,6 +1,7 @@ import filecmp import pytest + from PIL import Image, ImImagePlugin from .helper import assert_image_equal, hopper, is_pypy diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 1801cd8ff..03a2dba51 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -3,6 +3,7 @@ import re from io import BytesIO import pytest + from PIL import ( ExifTags, Image, diff --git a/Tests/test_file_jpeg2k.py b/Tests/test_file_jpeg2k.py index d558843b8..c9e37f8b0 100644 --- a/Tests/test_file_jpeg2k.py +++ b/Tests/test_file_jpeg2k.py @@ -2,6 +2,7 @@ import re from io import BytesIO import pytest + from PIL import Image, ImageFile, Jpeg2KImagePlugin, features from .helper import ( diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 22b048fc2..9ae166bff 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -7,6 +7,7 @@ from collections import namedtuple from ctypes import c_float import pytest + from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags, features from .helper import ( diff --git a/Tests/test_file_mcidas.py b/Tests/test_file_mcidas.py index 516dbb208..88c8f8f4f 100644 --- a/Tests/test_file_mcidas.py +++ b/Tests/test_file_mcidas.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, McIdasImagePlugin from .helper import assert_image_equal diff --git a/Tests/test_file_mic.py b/Tests/test_file_mic.py index 5003090c7..464d138e2 100644 --- a/Tests/test_file_mic.py +++ b/Tests/test_file_mic.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImagePalette from .helper import assert_image_similar, hopper, skip_unless_feature diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py index 893f9075d..791efcc3f 100644 --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -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 diff --git a/Tests/test_file_msp.py b/Tests/test_file_msp.py index 9b508a4e4..293b856b0 100644 --- a/Tests/test_file_msp.py +++ b/Tests/test_file_msp.py @@ -1,6 +1,7 @@ import os import pytest + from PIL import Image, MspImagePlugin from .helper import assert_image_equal, hopper diff --git a/Tests/test_file_palm.py b/Tests/test_file_palm.py index e7afeef23..25d194b62 100644 --- a/Tests/test_file_palm.py +++ b/Tests/test_file_palm.py @@ -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 diff --git a/Tests/test_file_pcx.py b/Tests/test_file_pcx.py index 5af7469c7..670c03b95 100644 --- a/Tests/test_file_pcx.py +++ b/Tests/test_file_pcx.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageFile, PcxImagePlugin from .helper import assert_image_equal, hopper diff --git a/Tests/test_file_pdf.py b/Tests/test_file_pdf.py index 14a7a654f..3e23beae7 100644 --- a/Tests/test_file_pdf.py +++ b/Tests/test_file_pdf.py @@ -5,6 +5,7 @@ import tempfile import time import pytest + from PIL import Image, PdfParser from .helper import hopper diff --git a/Tests/test_file_pixar.py b/Tests/test_file_pixar.py index 5e83c6104..315ea4676 100644 --- a/Tests/test_file_pixar.py +++ b/Tests/test_file_pixar.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, PixarImagePlugin from .helper import assert_image_similar, hopper diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 9891b6399..f59936741 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -3,6 +3,7 @@ import zlib from io import BytesIO import pytest + from PIL import Image, ImageFile, PngImagePlugin, features from .helper import ( diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 15c08e438..e7c3fb06f 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_image_equal, assert_image_similar, hopper diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index 6b26fe442..8bb45630e 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, PsdImagePlugin from .helper import assert_image_similar, hopper, is_pypy diff --git a/Tests/test_file_sgi.py b/Tests/test_file_sgi.py index cb16276ce..a197fa775 100644 --- a/Tests/test_file_sgi.py +++ b/Tests/test_file_sgi.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, SgiImagePlugin from .helper import assert_image_equal, assert_image_similar, hopper diff --git a/Tests/test_file_spider.py b/Tests/test_file_spider.py index 8c69491e6..9cdb451c9 100644 --- a/Tests/test_file_spider.py +++ b/Tests/test_file_spider.py @@ -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 diff --git a/Tests/test_file_sun.py b/Tests/test_file_sun.py index 03e26ef8b..4dcf1cb0c 100644 --- a/Tests/test_file_sun.py +++ b/Tests/test_file_sun.py @@ -1,6 +1,7 @@ import os import pytest + from PIL import Image, SunImagePlugin from .helper import assert_image_equal, assert_image_similar, hopper diff --git a/Tests/test_file_tar.py b/Tests/test_file_tar.py index 3fe0cd04e..02001e5b1 100644 --- a/Tests/test_file_tar.py +++ b/Tests/test_file_tar.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, TarIO, features from .helper import is_pypy diff --git a/Tests/test_file_tga.py b/Tests/test_file_tga.py index 4919ad766..e6eea605b 100644 --- a/Tests/test_file_tga.py +++ b/Tests/test_file_tga.py @@ -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 diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index cf22d647c..aefe6f9ea 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -2,6 +2,7 @@ import os from io import BytesIO import pytest + from PIL import Image, TiffImagePlugin from PIL.TiffImagePlugin import RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py index d57f63717..54a1f4163 100644 --- a/Tests/test_file_tiff_metadata.py +++ b/Tests/test_file_tiff_metadata.py @@ -2,6 +2,7 @@ import io import struct import pytest + from PIL import Image, TiffImagePlugin, TiffTags from PIL.TiffImagePlugin import IFDRational diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index 25a4bb8da..11fbd9fd5 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -2,6 +2,7 @@ import io import re import pytest + from PIL import Image, WebPImagePlugin, features from .helper import ( diff --git a/Tests/test_file_webp_alpha.py b/Tests/test_file_webp_alpha.py index c624156df..362edac1a 100644 --- a/Tests/test_file_webp_alpha.py +++ b/Tests/test_file_webp_alpha.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_image_equal, assert_image_similar, hopper diff --git a/Tests/test_file_webp_animated.py b/Tests/test_file_webp_animated.py index cd272f154..26e903488 100644 --- a/Tests/test_file_webp_animated.py +++ b/Tests/test_file_webp_animated.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import ( diff --git a/Tests/test_file_webp_lossless.py b/Tests/test_file_webp_lossless.py index 4d06f53b1..2da443628 100644 --- a/Tests/test_file_webp_lossless.py +++ b/Tests/test_file_webp_lossless.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_image_equal, hopper diff --git a/Tests/test_file_wmf.py b/Tests/test_file_wmf.py index 3339cbfd3..d18225680 100644 --- a/Tests/test_file_wmf.py +++ b/Tests/test_file_wmf.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, WmfImagePlugin from .helper import assert_image_similar, hopper diff --git a/Tests/test_file_xbm.py b/Tests/test_file_xbm.py index 23a540569..487920a92 100644 --- a/Tests/test_file_xbm.py +++ b/Tests/test_file_xbm.py @@ -1,6 +1,7 @@ from io import BytesIO import pytest + from PIL import Image from .helper import hopper diff --git a/Tests/test_file_xpm.py b/Tests/test_file_xpm.py index 187440d4e..8595b07eb 100644 --- a/Tests/test_file_xpm.py +++ b/Tests/test_file_xpm.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, XpmImagePlugin from .helper import assert_image_similar, hopper diff --git a/Tests/test_file_xvthumb.py b/Tests/test_file_xvthumb.py index 7c8c45113..ae53d2b63 100644 --- a/Tests/test_file_xvthumb.py +++ b/Tests/test_file_xvthumb.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, XVThumbImagePlugin from .helper import assert_image_similar, hopper diff --git a/Tests/test_font_bdf.py b/Tests/test_font_bdf.py index 4be39c383..1e7caee32 100644 --- a/Tests/test_font_bdf.py +++ b/Tests/test_font_bdf.py @@ -1,4 +1,5 @@ import pytest + from PIL import BdfFontFile, FontFile filename = "Tests/images/courB08.bdf" diff --git a/Tests/test_font_pcf.py b/Tests/test_font_pcf.py index a60163713..4db73e56e 100644 --- a/Tests/test_font_pcf.py +++ b/Tests/test_font_pcf.py @@ -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 diff --git a/Tests/test_image.py b/Tests/test_image.py index 068fb8172..cc0edbdd7 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -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 ( diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py index 57612c4b0..4c0dbb4cc 100644 --- a/Tests/test_image_access.py +++ b/Tests/test_image_access.py @@ -4,9 +4,9 @@ import subprocess import sys import sysconfig +import pytest from setuptools.command.build_ext import new_compiler -import pytest from PIL import Image from .helper import assert_image_equal, hopper, is_win32, on_ci @@ -17,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 diff --git a/Tests/test_image_array.py b/Tests/test_image_array.py index bf6d88a97..980458407 100644 --- a/Tests/test_image_array.py +++ b/Tests/test_image_array.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import hopper diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index cf83922b6..6fe1bd962 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_image, assert_image_equal, assert_image_similar, hopper diff --git a/Tests/test_image_crop.py b/Tests/test_image_crop.py index 3a2ce150d..e2228758c 100644 --- a/Tests/test_image_crop.py +++ b/Tests/test_image_crop.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_image_equal, hopper diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index ed71ea968..df8c353f3 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageFilter from .helper import assert_image_equal, hopper diff --git a/Tests/test_image_fromqimage.py b/Tests/test_image_fromqimage.py index 170d49ae1..5ad5b5c3c 100644 --- a/Tests/test_image_fromqimage.py +++ b/Tests/test_image_fromqimage.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageQt from .helper import assert_image_equal, hopper diff --git a/Tests/test_image_load.py b/Tests/test_image_load.py index efb9a1452..7dd3b294f 100644 --- a/Tests/test_image_load.py +++ b/Tests/test_image_load.py @@ -1,6 +1,7 @@ import os import pytest + from PIL import Image from .helper import hopper diff --git a/Tests/test_image_putpalette.py b/Tests/test_image_putpalette.py index 7b05e88b6..32f8de2c0 100644 --- a/Tests/test_image_putpalette.py +++ b/Tests/test_image_putpalette.py @@ -1,4 +1,5 @@ import pytest + from PIL import ImagePalette from .helper import hopper diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index 96fa143a9..192617a52 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_image, assert_image_similar, hopper diff --git a/Tests/test_image_reduce.py b/Tests/test_image_reduce.py index 0f92b87f8..8d847bbeb 100644 --- a/Tests/test_image_reduce.py +++ b/Tests/test_image_reduce.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageMath, ImageMode from .helper import convert_to_comparable, skip_unless_feature diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index 35eae128b..7e6fff7e2 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -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 diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py index ad4be135a..a49abe1b9 100644 --- a/Tests/test_image_resize.py +++ b/Tests/test_image_resize.py @@ -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 diff --git a/Tests/test_image_thumbnail.py b/Tests/test_image_thumbnail.py index da63efe55..c42310c32 100644 --- a/Tests/test_image_thumbnail.py +++ b/Tests/test_image_thumbnail.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import ( diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py index 3409d86f0..3ee51178d 100644 --- a/Tests/test_image_transform.py +++ b/Tests/test_image_transform.py @@ -1,6 +1,7 @@ import math import pytest + from PIL import Image, ImageTransform from .helper import assert_image_equal, assert_image_similar, hopper diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index e549f0922..0c15b2084 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -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 diff --git a/Tests/test_imagecolor.py b/Tests/test_imagecolor.py index d2fd07c81..b5d693796 100644 --- a/Tests/test_imagecolor.py +++ b/Tests/test_imagecolor.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageColor diff --git a/Tests/test_imagedraw.py b/Tests/test_imagedraw.py index 56b189ecd..224914b94 100644 --- a/Tests/test_imagedraw.py +++ b/Tests/test_imagedraw.py @@ -1,6 +1,7 @@ import os.path import pytest + from PIL import Image, ImageColor, ImageDraw, ImageFont from .helper import ( diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index 48fecc26e..e0dbd909a 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -1,6 +1,7 @@ from io import BytesIO import pytest + from PIL import EpsImagePlugin, Image, ImageFile, features from .helper import ( diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 6668a100b..aa7ec6fa6 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -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 ( diff --git a/Tests/test_imagefont_bitmap.py b/Tests/test_imagefont_bitmap.py index c4032d55d..337d2096e 100644 --- a/Tests/test_imagefont_bitmap.py +++ b/Tests/test_imagefont_bitmap.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageDraw, ImageFont from .helper import assert_image_similar diff --git a/Tests/test_imagefontctl.py b/Tests/test_imagefontctl.py index 386dd3be6..edd6fab57 100644 --- a/Tests/test_imagefontctl.py +++ b/Tests/test_imagefontctl.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageDraw, ImageFont from .helper import assert_image_similar, skip_unless_feature diff --git a/Tests/test_imagegrab.py b/Tests/test_imagegrab.py index ae1277ced..c36285451 100644 --- a/Tests/test_imagegrab.py +++ b/Tests/test_imagegrab.py @@ -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 diff --git a/Tests/test_imagemorph.py b/Tests/test_imagemorph.py index 62119e4b3..685a4e6b8 100644 --- a/Tests/test_imagemorph.py +++ b/Tests/test_imagemorph.py @@ -1,5 +1,6 @@ # Test the ImageMorphology functionality import pytest + from PIL import Image, ImageMorph, _imagingmorph from .helper import assert_image_equal, hopper diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 864df447e..5fbc0d3db 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageOps, features from .helper import ( diff --git a/Tests/test_imageops_usm.py b/Tests/test_imageops_usm.py index 61f8dc2ba..8837ed2a2 100644 --- a/Tests/test_imageops_usm.py +++ b/Tests/test_imageops_usm.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageFilter diff --git a/Tests/test_imagepalette.py b/Tests/test_imagepalette.py index 4ef2d3ffd..a2b0d2b02 100644 --- a/Tests/test_imagepalette.py +++ b/Tests/test_imagepalette.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImagePalette from .helper import assert_image_equal diff --git a/Tests/test_imagepath.py b/Tests/test_imagepath.py index 52af16455..7cc89ae39 100644 --- a/Tests/test_imagepath.py +++ b/Tests/test_imagepath.py @@ -2,6 +2,7 @@ import array import struct import pytest + from PIL import Image, ImagePath diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index d723690ef..c39bb0a06 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -1,4 +1,5 @@ import pytest + from PIL import ImageQt from .helper import hopper diff --git a/Tests/test_imagesequence.py b/Tests/test_imagesequence.py index b3fe9df97..7cf237b46 100644 --- a/Tests/test_imagesequence.py +++ b/Tests/test_imagesequence.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageSequence, TiffImagePlugin from .helper import assert_image_equal, hopper, skip_unless_feature diff --git a/Tests/test_imageshow.py b/Tests/test_imageshow.py index fddc73bd1..043a7aaae 100644 --- a/Tests/test_imageshow.py +++ b/Tests/test_imageshow.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageShow from .helper import hopper, is_win32, on_ci diff --git a/Tests/test_imagestat.py b/Tests/test_imagestat.py index 6c70193ce..9474ff6f9 100644 --- a/Tests/test_imagestat.py +++ b/Tests/test_imagestat.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageStat from .helper import hopper diff --git a/Tests/test_imagetk.py b/Tests/test_imagetk.py index d13920c16..a680c3171 100644 --- a/Tests/test_imagetk.py +++ b/Tests/test_imagetk.py @@ -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): diff --git a/Tests/test_imagewin.py b/Tests/test_imagewin.py index b1ddc75e9..9d64d17a3 100644 --- a/Tests/test_imagewin.py +++ b/Tests/test_imagewin.py @@ -1,4 +1,5 @@ import pytest + from PIL import ImageWin from .helper import hopper, is_win32 diff --git a/Tests/test_lib_image.py b/Tests/test_lib_image.py index 7115e62ad..37ed3659d 100644 --- a/Tests/test_lib_image.py +++ b/Tests/test_lib_image.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image diff --git a/Tests/test_lib_pack.py b/Tests/test_lib_pack.py index 8e3c1fda9..8a1460346 100644 --- a/Tests/test_lib_pack.py +++ b/Tests/test_lib_pack.py @@ -1,6 +1,7 @@ import sys import pytest + from PIL import Image X = 255 diff --git a/Tests/test_locale.py b/Tests/test_locale.py index c5e54883d..7a07fbbe0 100644 --- a/Tests/test_locale.py +++ b/Tests/test_locale.py @@ -1,6 +1,7 @@ import locale import pytest + from PIL import Image # ref https://github.com/python-pillow/Pillow/issues/272 diff --git a/Tests/test_map.py b/Tests/test_map.py index bdb59bfe0..2b65fb3f9 100644 --- a/Tests/test_map.py +++ b/Tests/test_map.py @@ -1,6 +1,7 @@ import sys import pytest + from PIL import Image from .helper import is_win32 diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 56addca1b..da367fa46 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image from .helper import assert_deep_equal, assert_image, hopper diff --git a/Tests/test_pdfparser.py b/Tests/test_pdfparser.py index f5cd403d5..2d428e95f 100644 --- a/Tests/test_pdfparser.py +++ b/Tests/test_pdfparser.py @@ -1,6 +1,7 @@ import time import pytest + from PIL.PdfParser import ( IndirectObjectDef, IndirectReference, diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index dd241fd74..a10dcec8c 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -1,6 +1,7 @@ import pickle import pytest + from PIL import Image from .helper import skip_unless_feature diff --git a/Tests/test_pyroma.py b/Tests/test_pyroma.py index f4302350d..aa05c2cfd 100644 --- a/Tests/test_pyroma.py +++ b/Tests/test_pyroma.py @@ -1,4 +1,5 @@ import pytest + from PIL import __version__ pyroma = pytest.importorskip("pyroma", reason="Pyroma not installed") diff --git a/Tests/test_qt_image_toqimage.py b/Tests/test_qt_image_toqimage.py index 4c98bf0b4..7f0b8351a 100644 --- a/Tests/test_qt_image_toqimage.py +++ b/Tests/test_qt_image_toqimage.py @@ -1,4 +1,5 @@ import pytest + from PIL import Image, ImageQt from .helper import assert_image_equal, hopper @@ -12,10 +13,10 @@ if ImageQt.qt_is_installed: try: from PyQt5 import QtGui - from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication + from PyQt5.QtWidgets import QApplication, QHBoxLayout, QLabel, QWidget except (ImportError, RuntimeError): from PySide2 import QtGui - from PySide2.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication + from PySide2.QtWidgets import QApplication, QHBoxLayout, QLabel, QWidget def test_sanity(tmp_path): diff --git a/Tests/test_sgi_crash.py b/Tests/test_sgi_crash.py index b1a3e1515..2b671244a 100644 --- a/Tests/test_sgi_crash.py +++ b/Tests/test_sgi_crash.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import pytest + from PIL import Image diff --git a/Tests/test_shell_injection.py b/Tests/test_shell_injection.py index 45c60fa10..d25d42dfc 100644 --- a/Tests/test_shell_injection.py +++ b/Tests/test_shell_injection.py @@ -1,6 +1,7 @@ import shutil import pytest + from PIL import GifImagePlugin, Image, JpegImagePlugin from .helper import cjpeg_available, djpeg_available, is_win32, netpbm_available diff --git a/Tests/test_util.py b/Tests/test_util.py index 3d88b9472..327abbfca 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -1,4 +1,5 @@ import pytest + from PIL import _util diff --git a/docs/conf.py b/docs/conf.py index caddae327..78841cc15 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,9 +16,10 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) -import PIL import sphinx_rtd_theme +import PIL + # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. diff --git a/setup.cfg b/setup.cfg index 19979cf77..b91a522f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,10 +3,7 @@ extend-ignore = E203, W503 max-line-length = 88 [isort] -combine_as_imports = True -include_trailing_comma = True -line_length = 88 -multi_line_output = 3 +profile = black [tool:pytest] addopts = -ra --color=yes diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py index 1d348b5a3..6243a6298 100644 --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -25,7 +25,12 @@ from . import Image, ImageFile, ImagePalette -from ._binary import i8, i16le as i16, i32le as i32, o8, o16le as o16, o32le as o32 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import i32le as i32 +from ._binary import o8 +from ._binary import o16le as o16 +from ._binary import o32le as o32 # # -------------------------------------------------------------------- diff --git a/src/PIL/CurImagePlugin.py b/src/PIL/CurImagePlugin.py index 3a1b6d2e5..35123f789 100644 --- a/src/PIL/CurImagePlugin.py +++ b/src/PIL/CurImagePlugin.py @@ -16,7 +16,9 @@ # See the README file for information on usage and redistribution. # from . import BmpImagePlugin, Image -from ._binary import i8, i16le as i16, i32le as i32 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import i32le as i32 # # -------------------------------------------------------------------- diff --git a/src/PIL/FliImagePlugin.py b/src/PIL/FliImagePlugin.py index f09d62ce3..a28f42320 100644 --- a/src/PIL/FliImagePlugin.py +++ b/src/PIL/FliImagePlugin.py @@ -17,7 +17,10 @@ from . import Image, ImageFile, ImagePalette -from ._binary import i8, i16le as i16, i32le as i32, o8 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import i32le as i32 +from ._binary import o8 # # decoder diff --git a/src/PIL/FpxImagePlugin.py b/src/PIL/FpxImagePlugin.py index bbee9e24d..21ba351f3 100644 --- a/src/PIL/FpxImagePlugin.py +++ b/src/PIL/FpxImagePlugin.py @@ -17,7 +17,8 @@ import olefile from . import Image, ImageFile -from ._binary import i8, i32le as i32 +from ._binary import i8 +from ._binary import i32le as i32 # we map from colour field tuples to (mode, rawmode) descriptors MODES = { diff --git a/src/PIL/GdImageFile.py b/src/PIL/GdImageFile.py index 0c4574f9e..8561f7b74 100644 --- a/src/PIL/GdImageFile.py +++ b/src/PIL/GdImageFile.py @@ -28,7 +28,9 @@ from . import ImageFile, ImagePalette, UnidentifiedImageError -from ._binary import i8, i16be as i16, i32be as i32 +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import i32be as i32 class GdImageFile(ImageFile.ImageFile): diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index 653051bb8..248c37ba1 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -30,7 +30,10 @@ import os import subprocess from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence -from ._binary import i8, i16le as i16, o8, o16le as o16 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import o8 +from ._binary import o16le as o16 # -------------------------------------------------------------------- # Identify/read GIF files diff --git a/src/PIL/IcoImagePlugin.py b/src/PIL/IcoImagePlugin.py index e4a74321b..57bb17ee9 100644 --- a/src/PIL/IcoImagePlugin.py +++ b/src/PIL/IcoImagePlugin.py @@ -28,7 +28,9 @@ from io import BytesIO from math import ceil, log from . import BmpImagePlugin, Image, ImageFile, PngImagePlugin -from ._binary import i8, i16le as i16, i32le as i32 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import i32le as i32 # # -------------------------------------------------------------------- diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index cbecf652d..33cb67923 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -35,7 +35,6 @@ import numbers from . import Image, ImageColor - """ A simple 2D drawing interface for PIL images.

diff --git a/src/PIL/ImageGrab.py b/src/PIL/ImageGrab.py index 3fa338b0a..b93ec3f2a 100644 --- a/src/PIL/ImageGrab.py +++ b/src/PIL/ImageGrab.py @@ -21,8 +21,8 @@ from . import Image if sys.platform == "darwin": import os - import tempfile import subprocess + import tempfile def grab(bbox=None, include_layered_windows=False, all_screens=False, xdisplay=None): diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index a15f4ab5e..15dde822a 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -29,11 +29,11 @@ qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=Tr for qt_version, qt_module in qt_versions: try: if qt_module == "PyQt5": - from PyQt5.QtGui import QImage, qRgba, QPixmap from PyQt5.QtCore import QBuffer, QIODevice + from PyQt5.QtGui import QImage, QPixmap, qRgba elif qt_module == "PySide2": - from PySide2.QtGui import QImage, qRgba, QPixmap from PySide2.QtCore import QBuffer, QIODevice + from PySide2.QtGui import QImage, QPixmap, qRgba except (ImportError, RuntimeError): continue qt_is_installed = True diff --git a/src/PIL/IptcImagePlugin.py b/src/PIL/IptcImagePlugin.py index 75e7b5a2a..f407b7e5f 100644 --- a/src/PIL/IptcImagePlugin.py +++ b/src/PIL/IptcImagePlugin.py @@ -18,7 +18,10 @@ import os import tempfile from . import Image, ImageFile -from ._binary import i8, i16be as i16, i32be as i32, o8 +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import o8 COMPRESSION = {1: "raw", 5: "jpeg"} @@ -181,9 +184,10 @@ def getiptcinfo(im): :returns: A dictionary containing IPTC information, or None if no IPTC information block was found. """ - from . import TiffImagePlugin, JpegImagePlugin import io + from . import JpegImagePlugin, TiffImagePlugin + data = None if isinstance(im, IptcImageFile): diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index f18eedb20..e2f7da9af 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -40,7 +40,10 @@ import tempfile import warnings from . import Image, ImageFile, TiffImagePlugin -from ._binary import i8, i16be as i16, i32be as i32, o8 +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import o8 from .JpegPresets import presets # diff --git a/src/PIL/MspImagePlugin.py b/src/PIL/MspImagePlugin.py index ca9572187..7abcefdd0 100644 --- a/src/PIL/MspImagePlugin.py +++ b/src/PIL/MspImagePlugin.py @@ -27,7 +27,9 @@ import io import struct from . import Image, ImageFile -from ._binary import i8, i16le as i16, o16le as o16 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import o16le as o16 # # read MSP files diff --git a/src/PIL/PalmImagePlugin.py b/src/PIL/PalmImagePlugin.py index 9fc55d795..dd9b1064d 100644 --- a/src/PIL/PalmImagePlugin.py +++ b/src/PIL/PalmImagePlugin.py @@ -8,7 +8,8 @@ ## from . import Image, ImageFile -from ._binary import o8, o16be as o16b +from ._binary import o8 +from ._binary import o16be as o16b # fmt: off _Palm8BitColormapValues = ( diff --git a/src/PIL/PcfFontFile.py b/src/PIL/PcfFontFile.py index f8836ad88..6a4eb22a6 100644 --- a/src/PIL/PcfFontFile.py +++ b/src/PIL/PcfFontFile.py @@ -19,7 +19,11 @@ import io from . import FontFile, Image -from ._binary import i8, i16be as b16, i16le as l16, i32be as b32, i32le as l32 +from ._binary import i8 +from ._binary import i16be as b16 +from ._binary import i16le as l16 +from ._binary import i32be as b32 +from ._binary import i32le as l32 # -------------------------------------------------------------------- # declarations diff --git a/src/PIL/PcxImagePlugin.py b/src/PIL/PcxImagePlugin.py index f7ae3bf70..ccf819c1b 100644 --- a/src/PIL/PcxImagePlugin.py +++ b/src/PIL/PcxImagePlugin.py @@ -29,7 +29,10 @@ import io import logging from . import Image, ImageFile, ImagePalette -from ._binary import i8, i16le as i16, o8, o16le as o16 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import o8 +from ._binary import o16le as o16 logger = logging.getLogger(__name__) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 9d048b211..0c53a031b 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -39,7 +39,12 @@ import warnings import zlib from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence -from ._binary import i8, i16be as i16, i32be as i32, o8, o16be as o16, o32be as o32 +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import i32be as i32 +from ._binary import o8 +from ._binary import o16be as o16 +from ._binary import o32be as o32 logger = logging.getLogger(__name__) diff --git a/src/PIL/PsdImagePlugin.py b/src/PIL/PsdImagePlugin.py index 80bc116fc..8d1dbf2b2 100644 --- a/src/PIL/PsdImagePlugin.py +++ b/src/PIL/PsdImagePlugin.py @@ -19,7 +19,9 @@ import io from . import Image, ImageFile, ImagePalette -from ._binary import i8, i16be as i16, i32be as i32 +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import i32be as i32 MODES = { # (photoshop mode, bits) -> (pil mode, required channels) diff --git a/src/PIL/SgiImagePlugin.py b/src/PIL/SgiImagePlugin.py index ec9855e77..88ba8d2c8 100644 --- a/src/PIL/SgiImagePlugin.py +++ b/src/PIL/SgiImagePlugin.py @@ -26,7 +26,9 @@ import os import struct from . import Image, ImageFile -from ._binary import i8, i16be as i16, o8 +from ._binary import i8 +from ._binary import i16be as i16 +from ._binary import o8 def _accept(prefix): diff --git a/src/PIL/TgaImagePlugin.py b/src/PIL/TgaImagePlugin.py index 566f0ac18..dc6efef5f 100644 --- a/src/PIL/TgaImagePlugin.py +++ b/src/PIL/TgaImagePlugin.py @@ -20,7 +20,10 @@ import warnings from . import Image, ImageFile, ImagePalette -from ._binary import i8, i16le as i16, o8, o16le as o16 +from ._binary import i8 +from ._binary import i16le as i16 +from ._binary import o8 +from ._binary import o16le as o16 # # -------------------------------------------------------------------- diff --git a/src/PIL/WmfImagePlugin.py b/src/PIL/WmfImagePlugin.py index 024222c9b..87847a107 100644 --- a/src/PIL/WmfImagePlugin.py +++ b/src/PIL/WmfImagePlugin.py @@ -20,7 +20,10 @@ # http://wvware.sourceforge.net/caolan/ora-wmf.html from . import Image, ImageFile -from ._binary import i16le as word, i32le as dword, si16le as short, si32le as _long +from ._binary import i16le as word +from ._binary import i32le as dword +from ._binary import si16le as short +from ._binary import si32le as _long _handler = None diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 53efd7884..41da45e45 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -356,8 +356,8 @@ def find_msvs(): def extract_dep(url, filename): - import urllib.request import tarfile + import urllib.request import zipfile file = os.path.join(depends_dir, filename)