From 1b338998dca28e7a170367c8d9014d6cf23f1379 Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 28 Sep 2015 22:24:45 +0300 Subject: [PATCH 01/19] Test a png file with iTXt chunks --- Tests/images/itxt_chunks.png | Bin 0 -> 69498 bytes Tests/test_pickle.py | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Tests/images/itxt_chunks.png diff --git a/Tests/images/itxt_chunks.png b/Tests/images/itxt_chunks.png new file mode 100644 index 0000000000000000000000000000000000000000..ca098440c15ba6b77aa4b656936dad05d01f1306 GIT binary patch literal 69498 zcmeI5du$X{6vk(_TRYtr8K|YJ0U3D+YAGxJVevtywAdDbRzpfLeQbfMBs?0r0jZeo z)B+(Itfai8yc9_k1r-H?h)ZoWAfYH?Q88{~M3Jf+35Zg_+1<|BdEA{CQ;pz9LO5Nz zGqb-r_dAb!=kBtiNqN1TH#s?u>s64S`!L5PdN?lOC~sF@Ir!z-KFU9d)%jCvI4&tA z^w-9{(CkuPOz;*=9GCD-Vrue@x2$u?Ta=du%$!`}&6zuUcGVoO@*~IP%&V&OR?QF> z%=A7k<`qmVnvqeJz;Pm1kefaE30vn^2PWn`B;-6Ky)7)eye(&ZpX~Iqu|GF=KKk2J zUGs~_RP1P9I?!f!@Pa7$IF@m@WB;7irWMTp>wcSDXN%jsAjbQ{zY}Qm$-$y8UhEs| zEXr@Wh1xia>u_A3=;C{?9C17ABGvcBZN3|qL3a~0v@Q)Apb<;u;2ZD__y!`ZHn#u` z(1?{x!Z+X>@QqNRfvQcdJwZd8LxKiqpxYB_tD*O$t*k%;G^jyoFyI^T4TDQi5QT5R zH{cuL>9c>OS-oiBq1%7Fm+u;L^Dn`*`=1X_|DEi6Vd0p$@vBxDCj%S%1$(!6-)re( zF}+t}i|eS}6MLS~!EcFAZa7`LcyO%3T6ymq_Ul^CRa>1VKgq=(JLk+J;V>H>YN?Mt7rIF0m( zUs|($N@gtA51s7}k679}&FVC7`($_7j%sbCYP?g$ereCm8CIv6X^X4eTi#*#2)fh0 z=98=MFSR<&r^*e4qv#3!bB^->*z< zCoXUlIEtc|NNly$dUr{H3P@KhgbBe>;3%T>&s9LEdeBob7B$FGkfR_+F^-BzE{_}q zIf~tZE-iKO$v}>x?^=h!z){FQ$bh53QIxU+6NHQ`6BC5ymMI(sjv|Oya=<7^u;joz z_xN`mrKxu0X>~1tZona5LB4`~#a#A>UO~Qse8px*80xt&gwTT}lEzFA6_9RJL^??b zJqSGrJ^IxVa@P5uPPFbC?0j+fz#E>aFG_b7zB!y9de^9R-`4%SWZJ^r>t8v2{M4!N z^8xZqn_T_J!ZOQ6{HX%JV`&OI_lvAg!BNbyKQws?F5p4}?Z-GWEHsL=6u?EV->T4p z3%IC703r!fIuK#mLj+vFMU#0UlCa$YT)+hp7PUQx zXV7Y25l^`!HrGu{8=^^rbZiw0L5HK|u@0+^Mg04GQs$M`jC@+RYBmCid_!A{<<24t zl_u-uWo3=V3(#DfKSkg-E*@!h8_y~qx+~>fk?AUtn<@_z;V=yU7T_>3>Ss6%d&t3I z;4mc52uXxOZy+SGGbT8U-cN`U9EMQn3^)uNM&l5ulGr6As-zetBpl`%ahR?<>vHr> z3;CPj!QU#bT>9|+Q-x~xL<0pxH_C!~{eS`}3IXIS<{6)!f)ZGh7D)#EFU4;^d*z3V{qrJu z-oBi`#f$sC-CSM}&HE%VkWlH%(7a+w5;ygA3&p?gWea#DFSXm^a1cX^4kl)$0~0Wj zpeIrJRmB!ez{Ku=JVG8JkA^%dA ziC);i(jzQA!qTH2U3!G&M*sbN3>I9RKOv4wZj~l{*ZYr;2kmwpC@6m^Jm)8m_e&)Q z&scpWC+|pZurYDw_dMuO4l6o|l!)fIn-u+zhy%TUdVJJN3dCPsj63%4Wb1SFE$RSbvGK88D#e zAp%O&o5^Maj7#V;9D3OUA^lKRjBcK3^LIC|*hDrho fp!{E(*cV>iHe~go4Fe`~%AbO9lXAC@_0<0foeHn% literal 0 HcmV?d00001 diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index bdfd3582d..f24cff612 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -67,7 +67,8 @@ class TestPickle(PillowTestCase): "Tests/images/non_zero_bb.png", "Tests/images/non_zero_bb_scale2.png", "Tests/images/p_trns_single.png", - "Tests/images/pil123p.png" + "Tests/images/pil123p.png", + "Tests/images/itxt_chunks.png" ]: self.helper_pickle_string(pickle, test_file=test_file) From 9dbaf92f3e2673fb9ad30643d7e0acb383ec67ca Mon Sep 17 00:00:00 2001 From: hugovk Date: Tue, 29 Sep 2015 08:36:07 +0300 Subject: [PATCH 02/19] itxt_chunks.png fails with protocol v2 --- Tests/test_pickle.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py index f24cff612..b6f5a5ae9 100644 --- a/Tests/test_pickle.py +++ b/Tests/test_pickle.py @@ -70,7 +70,10 @@ class TestPickle(PillowTestCase): "Tests/images/pil123p.png", "Tests/images/itxt_chunks.png" ]: - self.helper_pickle_string(pickle, test_file=test_file) + for protocol in range(0, pickle.HIGHEST_PROTOCOL + 1): + self.helper_pickle_string(pickle, + protocol=protocol, + test_file=test_file) def test_pickle_l_mode(self): # Arrange From f8df6d1687c2eba376b03b60a59b63c390c7d810 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 2 Jan 2019 18:56:54 +1100 Subject: [PATCH 03/19] Fixed pickling of iTXt class with protocol > 1 --- src/PIL/PngImagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 04161a56c..57d2f8341 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -192,7 +192,7 @@ class iTXt(str): """ @staticmethod - def __new__(cls, text, lang, tkey): + def __new__(cls, text, lang=None, tkey=None): """ :param cls: the class to use when creating the instance :param text: value for this key From c0f4382af275a808d88f7de0100ec1ab32c59e3c Mon Sep 17 00:00:00 2001 From: cgohlke Date: Sun, 6 Jan 2019 19:49:00 -0800 Subject: [PATCH 04/19] Add TIFF compression codecs: LZMA, Zstd, WebP --- src/PIL/TiffImagePlugin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index a39591937..665920b0e 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -133,6 +133,9 @@ COMPRESSION_INFO = { 32946: "tiff_deflate", 34676: "tiff_sgilog", 34677: "tiff_sgilog24", + 34925: "lzma", + 50000: "zstd", + 50001: "webp", } COMPRESSION_INFO_REV = {v: k for k, v in COMPRESSION_INFO.items()} From adae7ecc6a3c61c0850dbf62ae5807bba3c9df32 Mon Sep 17 00:00:00 2001 From: Will Badart Date: Mon, 28 Jan 2019 12:14:42 -0500 Subject: [PATCH 05/19] _util.isPath returns True for pathlib.Path objects Now, for functions which accept either a path or file object, the predicate will pass on Paths and not attempt to call .read on them before opening. The pathlib module was added in 3.4 but os.path functions did not start accepting path-like objects until 3.6, so that is the version after which this implementation is defined. Added a unit test to make sure isPath accepts Path objects. The unit test is skipped if python version is not 3.6 or later. --- Tests/test_util.py | 16 ++++++++++++++++ src/PIL/_util.py | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Tests/test_util.py b/Tests/test_util.py index 2316d3d65..dc18ba1e7 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -1,7 +1,11 @@ +import sys + from helper import unittest, PillowTestCase from PIL import _util +py36 = sys.version_info.major >= 3 and sys.version_info.minor >= 6 + class TestUtil(PillowTestCase): @@ -35,6 +39,18 @@ class TestUtil(PillowTestCase): # Assert self.assertTrue(it_is) + @unittest.skipIf(not py36, 'os.path support for Paths added in 3.6') + def test_path_obj_is_path(self): + # Arrange + from pathlib import Path + fp = Path('filename.ext') + + # Act + it_is = _util.isPath(fp) + + # Assert + self.assertTrue(it_is) + def test_is_not_path(self): # Arrange filename = self.tempfile("temp.ext") diff --git a/src/PIL/_util.py b/src/PIL/_util.py index 5828c2c24..d2062cb2f 100644 --- a/src/PIL/_util.py +++ b/src/PIL/_util.py @@ -2,13 +2,20 @@ import os import sys py3 = sys.version_info.major >= 3 +py36 = py3 and sys.version_info.minor >= 6 if py3: def isStringType(t): return isinstance(t, str) - def isPath(f): - return isinstance(f, (bytes, str)) + if py36: + from pathlib import Path + + def isPath(f): + return isinstance(f, (bytes, str, Path)) + else: + def isPath(f): + return isinstance(f, (bytes, str)) else: def isStringType(t): return isinstance(t, basestring) # noqa: F821 From 07bff3e9b8a34c85c8326525bd56b02d819a3352 Mon Sep 17 00:00:00 2001 From: Will Badart Date: Mon, 28 Jan 2019 19:45:53 -0500 Subject: [PATCH 06/19] Implement @hugovk's comments The `py36` flag now uses a tuple comparison to correctly handle future major version. The unit test file also now uses `py36` as exported by the _util module, rather than re-testing `sys.version_info`. --- Tests/test_util.py | 4 +--- src/PIL/_util.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Tests/test_util.py b/Tests/test_util.py index dc18ba1e7..6d7bfeeb0 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -4,8 +4,6 @@ from helper import unittest, PillowTestCase from PIL import _util -py36 = sys.version_info.major >= 3 and sys.version_info.minor >= 6 - class TestUtil(PillowTestCase): @@ -39,7 +37,7 @@ class TestUtil(PillowTestCase): # Assert self.assertTrue(it_is) - @unittest.skipIf(not py36, 'os.path support for Paths added in 3.6') + @unittest.skipIf(not _util.py36, 'os.path support for Paths added in 3.6') def test_path_obj_is_path(self): # Arrange from pathlib import Path diff --git a/src/PIL/_util.py b/src/PIL/_util.py index d2062cb2f..cb307050c 100644 --- a/src/PIL/_util.py +++ b/src/PIL/_util.py @@ -2,7 +2,7 @@ import os import sys py3 = sys.version_info.major >= 3 -py36 = py3 and sys.version_info.minor >= 6 +py36 = sys.version_info[0:2] >= (3, 6) if py3: def isStringType(t): From c328ecace3b28bc25c287401b4415ad2ad718b69 Mon Sep 17 00:00:00 2001 From: Will Badart Date: Mon, 28 Jan 2019 20:08:25 -0500 Subject: [PATCH 07/19] Fix lint error Removed missing import in test_util.py. Stopped needing it after I started reusing the py36 test from the _util module. --- Tests/test_util.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/test_util.py b/Tests/test_util.py index 6d7bfeeb0..ea4a2f962 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -1,5 +1,3 @@ -import sys - from helper import unittest, PillowTestCase from PIL import _util From dd1e7ccc4aacde8972f7b2573a2b5029e2cb222d Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 3 Feb 2019 07:13:28 -0800 Subject: [PATCH 08/19] Slightly simplify Image.__eq__ Two identical types can be compared using the `is` operator. Object identity is slightly faster than a string comparison as well. --- src/PIL/Image.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index ef4a7a88a..62e5051fc 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -655,8 +655,7 @@ class Image(object): return filename def __eq__(self, other): - return (isinstance(other, Image) and - self.__class__.__name__ == other.__class__.__name__ and + return (self.__class__ is other.__class__ and self.mode == other.mode and self.size == other.size and self.info == other.info and From aed56efa5050d032af3afe293142483cb53e125a Mon Sep 17 00:00:00 2001 From: Hugo Date: Mon, 4 Feb 2019 10:36:34 -0500 Subject: [PATCH 09/19] Apply suggestions from code review Rename `fp` to `test_path` in the new `test_is_path` test. ^ Wow, what a sentence... Co-Authored-By: wbadart --- Tests/test_util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/test_util.py b/Tests/test_util.py index ea4a2f962..86999c89f 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -39,10 +39,10 @@ class TestUtil(PillowTestCase): def test_path_obj_is_path(self): # Arrange from pathlib import Path - fp = Path('filename.ext') + test_path = Path('filename.ext') # Act - it_is = _util.isPath(fp) + it_is = _util.isPath(test_path) # Assert self.assertTrue(it_is) From 1793f6bd523a766dad2bd8a23cf7fcfbe3858972 Mon Sep 17 00:00:00 2001 From: Hugo Date: Tue, 12 Feb 2019 16:58:59 +0200 Subject: [PATCH 10/19] Document deprecated image plugin version constants (#3628) --- docs/deprecations.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/deprecations.rst b/docs/deprecations.rst index adbf0f85f..071cf79bf 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -12,6 +12,31 @@ Deprecated features Below are features which are considered deprecated. Where appropriate, a ``DeprecationWarning`` is issued. +PIL.*ImagePlugin.__version__ attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 6.0.0 + +The version constants of individuals plugins have been deprecated and will be removed in +a future version. Use ``PIL.__version__`` instead. + +=============================== ================================= ================================== +Deprecated Deprecated Deprecated +=============================== ================================= ================================== +``BmpImagePlugin.__version__`` ``Jpeg2KImagePlugin.__version__`` ``PngImagePlugin.__version__`` +``CurImagePlugin.__version__`` ``JpegImagePlugin.__version__`` ``PpmImagePlugin.__version__`` +``DcxImagePlugin.__version__`` ``McIdasImagePlugin.__version__`` ``PsdImagePlugin.__version__`` +``EpsImagePlugin.__version__`` ``MicImagePlugin.__version__`` ``SgiImagePlugin.__version__`` +``FliImagePlugin.__version__`` ``MpegImagePlugin.__version__`` ``SunImagePlugin.__version__`` +``FpxImagePlugin.__version__`` ``MpoImagePlugin.__version__`` ``TgaImagePlugin.__version__`` +``GdImageFile.__version__`` ``MspImagePlugin.__version__`` ``TiffImagePlugin.__version__`` +``GifImagePlugin.__version__`` ``PalmImagePlugin.__version__`` ``WmfImagePlugin.__version__`` +``IcoImagePlugin.__version__`` ``PcdImagePlugin.__version__`` ``XbmImagePlugin.__version__`` +``ImImagePlugin.__version__`` ``PcxImagePlugin.__version__`` ``XpmImagePlugin.__version__`` +``ImtImagePlugin.__version__`` ``PdfImagePlugin.__version__`` ``XVThumbImagePlugin.__version__`` +``IptcImagePlugin.__version__`` ``PixarImagePlugin.__version__`` +=============================== ================================= ================================== + Setting the size of TIFF images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From f95b98a59c690031ff0078d82774c62f29a47641 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Wed, 13 Feb 2019 10:36:12 +0200 Subject: [PATCH 11/19] Fix typo Co-Authored-By: hugovk --- docs/deprecations.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 071cf79bf..b8131ac05 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -17,7 +17,7 @@ PIL.*ImagePlugin.__version__ attributes .. deprecated:: 6.0.0 -The version constants of individuals plugins have been deprecated and will be removed in +The version constants of individual plugins have been deprecated and will be removed in a future version. Use ``PIL.__version__`` instead. =============================== ================================= ================================== From 3c088db7bac783e2688ac7beac43ad80cfa0987f Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 14 Feb 2019 22:59:14 +0200 Subject: [PATCH 12/19] Depreate support for EOL PyQt4 and PySide --- Tests/test_imageqt.py | 10 ++++++++++ src/PIL/ImageQt.py | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index 2ded37c09..f0e5a4613 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -2,6 +2,12 @@ from .helper import PillowTestCase, hopper from PIL import ImageQt +try: + # Python 3 + from importlib import reload +except ImportError: + # Python 2.7 + pass if ImageQt.qt_is_installed: from PIL.ImageQt import qRgba @@ -78,3 +84,7 @@ class TestImageQt(PillowQtTestCase, PillowTestCase): def test_image(self): for mode in ('1', 'RGB', 'RGBA', 'L', 'P'): ImageQt.ImageQt(hopper(mode)) + + def test_deprecated(self): + expected = DeprecationWarning if ImageQt.qt_version in ["4", "side"] else None + self.assert_warning(expected, reload, ImageQt) diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index b747781c5..02ce6354e 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -20,6 +20,7 @@ from . import Image from ._util import isPath, py3 from io import BytesIO import sys +import warnings qt_versions = [ ['5', 'PyQt5'], @@ -27,6 +28,12 @@ qt_versions = [ ['4', 'PyQt4'], ['side', 'PySide'] ] + +WARNING_TEXT = ( + "Support for EOL {} is deprecated and will be removed in a future version. " + "Please upgrade to PyQt5 or PySide2." +) + # If a version has already been imported, attempt it first qt_versions.sort(key=lambda qt_version: qt_version[1] in sys.modules, reverse=True) @@ -41,9 +48,13 @@ for qt_version, qt_module in qt_versions: elif qt_module == 'PyQt4': from PyQt4.QtGui import QImage, qRgba, QPixmap from PyQt4.QtCore import QBuffer, QIODevice + + warnings.warn(WARNING_TEXT.format(qt_module), DeprecationWarning) elif qt_module == 'PySide': from PySide.QtGui import QImage, qRgba, QPixmap from PySide.QtCore import QBuffer, QIODevice + + warnings.warn(WARNING_TEXT.format(qt_module), DeprecationWarning) except (ImportError, RuntimeError): continue qt_is_installed = True @@ -67,7 +78,7 @@ def fromqimage(im): """ buffer = QBuffer() buffer.open(QIODevice.ReadWrite) - # preserve alha channel with png + # preserve alpha channel with png # otherwise ppm is more friendly with Image.open if im.hasAlphaChannel(): im.save(buffer, 'png') From 186f7d943bf213abbaa508b23c06fc001e8b6ec7 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 14 Feb 2019 23:44:07 +0200 Subject: [PATCH 13/19] Document deprecation --- docs/deprecations.rst | 12 ++++++++++++ docs/reference/ImageQt.rst | 6 ++++++ docs/releasenotes/6.0.0.rst | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/docs/deprecations.rst b/docs/deprecations.rst index adbf0f85f..12367ce6e 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -12,6 +12,18 @@ Deprecated features Below are features which are considered deprecated. Where appropriate, a ``DeprecationWarning`` is issued. + +PyQt4 and PySide +~~~~~~~~~~~~~~~~ + +.. deprecated:: 6.0.0 + +Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since +2018-08-31 and PySide since 2015-10-14. + +Support for PyQt4 and PySide has been deprecated from ``ImageQt`` and will be removed in +a future version. Please upgrade to PyQt5 or PySide2. + Setting the size of TIFF images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/reference/ImageQt.rst b/docs/reference/ImageQt.rst index 386401075..5128f28fb 100644 --- a/docs/reference/ImageQt.rst +++ b/docs/reference/ImageQt.rst @@ -7,6 +7,12 @@ The :py:mod:`ImageQt` module contains support for creating PyQt4, PyQt5, PySide or PySide2 QImage objects from PIL images. +Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since +2018-08-31 and PySide since 2015-10-14. + +Support for PyQt4 and PySide is deprecated since Pillow 6.0.0 and will be removed in a +future version. Please upgrade to PyQt5 or PySide2. + .. versionadded:: 1.1.6 .. py:class:: ImageQt.ImageQt(image) diff --git a/docs/releasenotes/6.0.0.rst b/docs/releasenotes/6.0.0.rst index e1fa83cce..9fbb3d69a 100644 --- a/docs/releasenotes/6.0.0.rst +++ b/docs/releasenotes/6.0.0.rst @@ -32,6 +32,18 @@ API Changes Deprecations ^^^^^^^^^^^^ +PyQt4 and PySide +~~~~~~~~~~~~~~~~ + +Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since +2018-08-31 and PySide since 2015-10-14. + +Support for PyQt4 and PySide has been deprecated from ``ImageQt`` and will be removed in +a future version. Please upgrade to PyQt5 or PySide2. + +PIL.*ImagePlugin.__version__ attributes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + These version constants have been deprecated and will be removed in a future version. From 6e1227765e89b8e2994b1fdfaa096ed26c0a5d54 Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 15 Feb 2019 10:13:03 +0200 Subject: [PATCH 14/19] Move PyQt4/PySide above plugin constants Both deprecated in the same version, but PyQt4/PySide has a bigger impact --- docs/deprecations.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 605ceb4ac..bc4e83161 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -12,6 +12,17 @@ Deprecated features Below are features which are considered deprecated. Where appropriate, a ``DeprecationWarning`` is issued. +PyQt4 and PySide +~~~~~~~~~~~~~~~~ + +.. deprecated:: 6.0.0 + +Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since +2018-08-31 and PySide since 2015-10-14. + +Support for PyQt4 and PySide has been deprecated from ``ImageQt`` and will be removed in +a future version. Please upgrade to PyQt5 or PySide2. + PIL.*ImagePlugin.__version__ attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -37,17 +48,6 @@ Deprecated Deprecated Deprecated ``IptcImagePlugin.__version__`` ``PixarImagePlugin.__version__`` =============================== ================================= ================================== -PyQt4 and PySide -~~~~~~~~~~~~~~~~ - -.. deprecated:: 6.0.0 - -Qt 4 reached end-of-life on 2015-12-19. Its Python bindings are also EOL: PyQt4 since -2018-08-31 and PySide since 2015-10-14. - -Support for PyQt4 and PySide has been deprecated from ``ImageQt`` and will be removed in -a future version. Please upgrade to PyQt5 or PySide2. - Setting the size of TIFF images ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 38b5255f58a9ff025f1237e1bd47d5fb162f90cf Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 16 Feb 2019 12:36:10 +1100 Subject: [PATCH 15/19] Catch DeprecationWarning from initial import --- Tests/test_imageqt.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index f0e5a4613..bd93828ef 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -1,13 +1,16 @@ from .helper import PillowTestCase, hopper -from PIL import ImageQt +import warnings -try: - # Python 3 - from importlib import reload -except ImportError: - # Python 2.7 - pass +deprecated = False +with warnings.catch_warnings(): + warnings.filterwarnings("error", category=DeprecationWarning) + try: + from PIL import ImageQt + except DeprecationWarning: + deprecated = True + warnings.filterwarnings("ignore", category=DeprecationWarning) + from PIL import ImageQt if ImageQt.qt_is_installed: from PIL.ImageQt import qRgba @@ -86,5 +89,4 @@ class TestImageQt(PillowQtTestCase, PillowTestCase): ImageQt.ImageQt(hopper(mode)) def test_deprecated(self): - expected = DeprecationWarning if ImageQt.qt_version in ["4", "side"] else None - self.assert_warning(expected, reload, ImageQt) + self.assertEqual(ImageQt.qt_version in ["4", "side"], deprecated) From 9e52fb0fe4ec6652f0fdf47723c0b1fef75dbe5a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 19 Feb 2019 19:45:53 +1100 Subject: [PATCH 16/19] Use constants for tag types --- src/PIL/TiffImagePlugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index a0609bb4f..3c00d92ae 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -423,7 +423,7 @@ class ImageFileDirectory_v2(MutableMapping): ifd = ImageFileDirectory_v2() ifd[key] = 'Some Data' - ifd.tagtype[key] = 2 + ifd.tagtype[key] = TiffTags.ASCII print(ifd[key]) 'Some Data' @@ -557,7 +557,7 @@ class ImageFileDirectory_v2(MutableMapping): if info.type: self.tagtype[tag] = info.type else: - self.tagtype[tag] = 7 + self.tagtype[tag] = TiffTags.UNDEFINED if all(isinstance(v, IFDRational) for v in values): self.tagtype[tag] = TiffTags.RATIONAL elif all(isinstance(v, int) for v in values): @@ -872,7 +872,7 @@ class ImageFileDirectory_v1(ImageFileDirectory_v2): ifd = ImageFileDirectory_v1() ifd[key] = 'Some Data' - ifd.tagtype[key] = 2 + ifd.tagtype[key] = TiffTags.ASCII print(ifd[key]) ('Some Data',) From 26db1824ba6ad03f2457af15a2832eda325c0b0a Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 20 Feb 2019 11:53:19 +0200 Subject: [PATCH 17/19] Update CHANGES.rst --- CHANGES.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index e1c08d8bd..d82455616 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,15 @@ Changelog (Pillow) 6.0.0 (unreleased) ------------------ +- Add TIFF compression codecs: LZMA, Zstd, WebP #3555 + [cgohlke] + +- Fixed pickling of iTXt class with protocol > 1 #3537 + [radarhere] + +- _util.isPath returns True for pathlib.Path objects #3616 + [wbadart] + - Remove unnecessary unittest.main() boilerplate from test files #3631 [jdufresne] From d07d3d6972b4f944e963e137677609e88d55afa6 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 20 Feb 2019 20:57:52 +1100 Subject: [PATCH 18/19] Restored required import --- Tests/test_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/test_util.py b/Tests/test_util.py index 4dfc6ffef..08e9c1665 100644 --- a/Tests/test_util.py +++ b/Tests/test_util.py @@ -1,4 +1,4 @@ -from .helper import PillowTestCase +from .helper import unittest, PillowTestCase from PIL import _util From e9fd0192faf1aac354ef76b633eac6cfc673d1e1 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 21 Feb 2019 19:25:27 +1100 Subject: [PATCH 19/19] Update CHANGES.rst [ci skip] --- CHANGES.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index d82455616..eee909695 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,12 +5,15 @@ Changelog (Pillow) 6.0.0 (unreleased) ------------------ +- Deprecate support for PyQt4 and PySide #3655 + [hugovk, radarhere] + - Add TIFF compression codecs: LZMA, Zstd, WebP #3555 [cgohlke] - Fixed pickling of iTXt class with protocol > 1 #3537 [radarhere] - + - _util.isPath returns True for pathlib.Path objects #3616 [wbadart]