Skip to content

Commit

Permalink
Merge 485ea4e into 211a1da
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Oct 1, 2019
2 parents 211a1da + 485ea4e commit b9dc759
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 70 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -24,9 +24,6 @@ matrix:
name: "3.7 Xenial"
- python: '2.7'
name: "2.7 Xenial"
- python: "2.7_with_system_site_packages" # For PyQt4
name: "2.7_with_system_site_packages Xenial"
services: xvfb
- python: '3.6'
name: "3.6 Xenial PYTHONOPTIMIZE=1"
env: PYTHONOPTIMIZE=1
Expand Down
8 changes: 0 additions & 8 deletions Tests/test_imageqt.py
Expand Up @@ -35,10 +35,6 @@ def setUp(self):
try:
if ImageQt.qt_version == "5":
from PyQt5.QtGui import QGuiApplication
elif ImageQt.qt_version == "4":
from PyQt4.QtGui import QGuiApplication
elif ImageQt.qt_version == "side":
from PySide.QtGui import QGuiApplication
elif ImageQt.qt_version == "side2":
from PySide2.QtGui import QGuiApplication
except ImportError:
Expand All @@ -59,10 +55,6 @@ def test_rgb(self):
# equivalent to an unsigned int.
if ImageQt.qt_version == "5":
from PyQt5.QtGui import qRgb
elif ImageQt.qt_version == "4":
from PyQt4.QtGui import qRgb
elif ImageQt.qt_version == "side":
from PySide.QtGui import qRgb
elif ImageQt.qt_version == "side2":
from PySide2.QtGui import qRgb

Expand Down
24 changes: 2 additions & 22 deletions Tests/test_qt_image_toqimage.py
Expand Up @@ -9,25 +9,9 @@
try:
from PyQt5 import QtGui
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication

QT_VERSION = 5
except (ImportError, RuntimeError):
try:
from PySide2 import QtGui
from PySide2.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication

QT_VERSION = 5
except (ImportError, RuntimeError):
try:
from PyQt4 import QtGui
from PyQt4.QtGui import QWidget, QHBoxLayout, QLabel, QApplication

QT_VERSION = 4
except (ImportError, RuntimeError):
from PySide import QtGui
from PySide.QtGui import QWidget, QHBoxLayout, QLabel, QApplication

QT_VERSION = 4
from PySide2 import QtGui
from PySide2.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication


class TestToQImage(PillowQtTestCase, PillowTestCase):
Expand Down Expand Up @@ -60,10 +44,6 @@ def test_sanity(self):

# Check that it actually worked.
reloaded = Image.open(tempfile)
# Gray images appear to come back in palette mode.
# They're roughly equivalent
if QT_VERSION == 4 and mode == "L":
src = src.convert("P")
self.assert_image_equal(reloaded, src)

def test_segfault(self):
Expand Down
22 changes: 11 additions & 11 deletions docs/deprecations.rst
Expand Up @@ -45,17 +45,6 @@ Python 2.7 reaches end-of-life on 2020-01-01.
Pillow 7.0.0 will be released on 2020-01-01 and will drop support for Python 2.7, making
Pillow 6.x the last series to support Python 2.

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -128,6 +117,17 @@ Removed features
Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed.

PyQt4 and PySide
~~~~~~~~~~~~~~~~

*Removed in version 7.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 removed from ``ImageQt``. Please upgrade to PyQt5
or PySide2.

VERSION constant
~~~~~~~~~~~~~~~~

Expand Down
12 changes: 3 additions & 9 deletions docs/reference/ImageQt.rst
Expand Up @@ -4,14 +4,8 @@
:py:mod:`ImageQt` Module
========================

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.
The :py:mod:`ImageQt` module contains support for creating PyQt5 or PySide2 QImage
objects from PIL images.

.. versionadded:: 1.1.6

Expand All @@ -20,7 +14,7 @@ future version. Please upgrade to PyQt5 or PySide2.
Creates an :py:class:`~PIL.ImageQt.ImageQt` object from a PIL
:py:class:`~PIL.Image.Image` object. This class is a subclass of
QtGui.QImage, which means that you can pass the resulting objects directly
to PyQt4/PyQt5/PySide API functions and methods.
to PyQt5/PySide2 API functions and methods.

This operation is currently supported for mode 1, L, P, RGB, and RGBA
images. To handle other modes, you need to convert the image first.
18 changes: 1 addition & 17 deletions src/PIL/ImageQt.py
Expand Up @@ -17,18 +17,12 @@
#

import sys
import warnings
from io import BytesIO

from . import Image
from ._util import isPath, py3

qt_versions = [["5", "PyQt5"], ["side2", "PySide2"], ["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."
)
qt_versions = [["5", "PyQt5"], ["side2", "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)
Expand All @@ -40,16 +34,6 @@
elif qt_module == "PySide2":
from PySide2.QtGui import QImage, qRgba, QPixmap
from PySide2.QtCore import QBuffer, QIODevice
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
Expand Down

0 comments on commit b9dc759

Please sign in to comment.