deprecate EpsImagePlugin.PSFile

This commit is contained in:
Yay295 2023-02-06 17:23:57 -06:00
parent be9aea35a8
commit bd0fac80c4
5 changed files with 36 additions and 1 deletions

View File

@ -311,6 +311,7 @@ def test_read_binary_preview():
pass pass
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
def test_readline_psfile(tmp_path): def test_readline_psfile(tmp_path):
# check all the freaking line endings possible from the spec # check all the freaking line endings possible from the spec
# test_string = u'something\r\nelse\n\rbaz\rbif\n' # test_string = u'something\r\nelse\n\rbaz\rbif\n'
@ -346,6 +347,11 @@ def test_readline_psfile(tmp_path):
_test_readline_file_psfile(s, ending) _test_readline_file_psfile(s, ending)
def test_psfile_deprecation():
with pytest.warns(DeprecationWarning):
EpsImagePlugin.PSFile(None)
@pytest.mark.parametrize("prefix", (b"", simple_binary_header)) @pytest.mark.parametrize("prefix", (b"", simple_binary_header))
@pytest.mark.parametrize( @pytest.mark.parametrize(
"line_ending", "line_ending",

View File

@ -80,6 +80,16 @@ A number of constants have been deprecated and will be removed in Pillow 10.0.0
was reversed in Pillow 9.4.0 and those constants will now remain available. was reversed in Pillow 9.4.0 and those constants will now remain available.
See :ref:`restored-image-constants` See :ref:`restored-image-constants`
PSFile
~~~~~~
.. deprecated:: 9.4.0
The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will
be removed in Pillow 11 (2024-10-15). This class was only made as a helper to
be used internally, so there is no replacement. If you need this functionality
though, it is a very short class that can easily be recreated in your own code.
===================================================== ============================================================ ===================================================== ============================================================
Deprecated Use instead Deprecated Use instead
===================================================== ============================================================ ===================================================== ============================================================

View File

@ -1,6 +1,17 @@
9.4.0 9.4.0
----- -----
Deprecations
============
PSFile
^^^^^^
The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will
be removed in Pillow 11 (2024-10-15). This class was only made as a helper to
be used internally, so there is no replacement. If you need this functionality
though, it is a very short class that can easily be recreated in your own code.
API Additions API Additions
============= =============

View File

@ -29,6 +29,7 @@ import tempfile
from . import Image, ImageFile from . import Image, ImageFile
from ._binary import i32le as i32 from ._binary import i32le as i32
from ._deprecate import deprecate
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -166,6 +167,11 @@ class PSFile:
""" """
def __init__(self, fp): def __init__(self, fp):
deprecate(
"PSFile",
11,
action="If you need the functionality of this class you will need to implement it yourself.",
)
self.fp = fp self.fp = fp
self.char = None self.char = None

View File

@ -47,8 +47,10 @@ def deprecate(
raise RuntimeError(msg) raise RuntimeError(msg)
elif when == 10: elif when == 10:
removed = "Pillow 10 (2023-07-01)" removed = "Pillow 10 (2023-07-01)"
elif when == 11:
removed = "Pillow 11 (2024-10-15)"
else: else:
msg = f"Unknown removal version, update {__name__}?" msg = f"Unknown removal version: {when}. Update {__name__}?"
raise ValueError(msg) raise ValueError(msg)
if replacement and action: if replacement and action: