mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Deprecated _showxv
This commit is contained in:
parent
c9745f4b51
commit
ee06255ff0
|
@ -5,7 +5,7 @@ import tempfile
|
||||||
|
|
||||||
import PIL
|
import PIL
|
||||||
import pytest
|
import pytest
|
||||||
from PIL import Image, ImageDraw, ImagePalette, UnidentifiedImageError
|
from PIL import Image, ImageDraw, ImagePalette, ImageShow, UnidentifiedImageError
|
||||||
|
|
||||||
from .helper import (
|
from .helper import (
|
||||||
assert_image_equal,
|
assert_image_equal,
|
||||||
|
@ -585,6 +585,22 @@ class TestImage:
|
||||||
expected = Image.new(mode, (100, 100), color)
|
expected = Image.new(mode, (100, 100), color)
|
||||||
assert_image_equal(im.convert(mode), expected)
|
assert_image_equal(im.convert(mode), expected)
|
||||||
|
|
||||||
|
def test_showxv_deprecation(self):
|
||||||
|
class TestViewer(ImageShow.Viewer):
|
||||||
|
def show_image(self, image, **options):
|
||||||
|
return True
|
||||||
|
|
||||||
|
viewer = TestViewer()
|
||||||
|
ImageShow.register(viewer, -1)
|
||||||
|
|
||||||
|
im = Image.new("RGB", (50, 50), "white")
|
||||||
|
|
||||||
|
with pytest.warns(DeprecationWarning):
|
||||||
|
Image._showxv(im)
|
||||||
|
|
||||||
|
# Restore original state
|
||||||
|
ImageShow._viewers.pop(0)
|
||||||
|
|
||||||
def test_no_resource_warning_on_save(self, tmp_path):
|
def test_no_resource_warning_on_save(self, tmp_path):
|
||||||
# https://github.com/python-pillow/Pillow/issues/835
|
# https://github.com/python-pillow/Pillow/issues/835
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
|
@ -20,6 +20,15 @@ Image.show command parameter
|
||||||
The ``command`` parameter was deprecated and will be removed in a future release.
|
The ``command`` parameter was deprecated and will be removed in a future release.
|
||||||
Use a subclass of ``ImageShow.Viewer`` instead.
|
Use a subclass of ``ImageShow.Viewer`` instead.
|
||||||
|
|
||||||
|
Image._showxv
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. deprecated:: 7.2.0
|
||||||
|
|
||||||
|
``Image._showxv`` has been deprecated. Use :py:meth:`~PIL.Image.Image.show`
|
||||||
|
instead. If custom behaviour is required, use :py:meth:`~PIL.ImageShow.register` to add
|
||||||
|
a custom :py:class:`~PIL.ImageShow.Viewer` class.
|
||||||
|
|
||||||
ImageFile.raise_ioerror
|
ImageFile.raise_ioerror
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,13 @@ Image.show command parameter
|
||||||
The ``command`` parameter was deprecated and will be removed in a future release.
|
The ``command`` parameter was deprecated and will be removed in a future release.
|
||||||
Use a subclass of :py:class:`PIL.ImageShow.Viewer` instead.
|
Use a subclass of :py:class:`PIL.ImageShow.Viewer` instead.
|
||||||
|
|
||||||
|
Image._showxv
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
``Image._showxv`` has been deprecated. Use :py:meth:`~PIL.Image.Image.show`
|
||||||
|
instead. If custom behaviour is required, use :py:meth:`~PIL.ImageShow.register` to add
|
||||||
|
a custom :py:class:`~PIL.ImageShow.Viewer` class.
|
||||||
|
|
||||||
ImageFile.raise_ioerror
|
ImageFile.raise_ioerror
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -3150,12 +3150,21 @@ def register_encoder(name, encoder):
|
||||||
|
|
||||||
|
|
||||||
def _show(image, **options):
|
def _show(image, **options):
|
||||||
|
options["_internal_pillow"] = True
|
||||||
_showxv(image, **options)
|
_showxv(image, **options)
|
||||||
|
|
||||||
|
|
||||||
def _showxv(image, title=None, **options):
|
def _showxv(image, title=None, **options):
|
||||||
from . import ImageShow
|
from . import ImageShow
|
||||||
|
|
||||||
|
if "_internal_pillow" in options:
|
||||||
|
del options["_internal_pillow"]
|
||||||
|
else:
|
||||||
|
warnings.warn(
|
||||||
|
"_showxv is deprecated and will be removed in a future release. "
|
||||||
|
"Use Image.show instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
)
|
||||||
ImageShow.show(image, title, **options)
|
ImageShow.show(image, title, **options)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user