diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 5d63df4a6..e4c1000e2 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -311,6 +311,7 @@ def test_read_binary_preview(): pass +@pytest.mark.filterwarnings("ignore::DeprecationWarning") def test_readline_psfile(tmp_path): # check all the freaking line endings possible from the spec # 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) +def test_psfile_deprecation(): + with pytest.warns(DeprecationWarning): + EpsImagePlugin.PSFile(None) + + @pytest.mark.parametrize("prefix", (b"", simple_binary_header)) @pytest.mark.parametrize( "line_ending", diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 4d48b822a..c31b0dac9 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -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. 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 ===================================================== ============================================================ diff --git a/docs/releasenotes/9.4.0.rst b/docs/releasenotes/9.4.0.rst index 0af5bc8ca..b7a63dd61 100644 --- a/docs/releasenotes/9.4.0.rst +++ b/docs/releasenotes/9.4.0.rst @@ -1,6 +1,17 @@ 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 ============= diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py index 2a4e804ce..6c63ef08a 100644 --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -29,6 +29,7 @@ import tempfile from . import Image, ImageFile from ._binary import i32le as i32 +from ._deprecate import deprecate # # -------------------------------------------------------------------- @@ -166,6 +167,11 @@ class PSFile: """ 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.char = None diff --git a/src/PIL/_deprecate.py b/src/PIL/_deprecate.py index 7c4b1623d..81f2189dc 100644 --- a/src/PIL/_deprecate.py +++ b/src/PIL/_deprecate.py @@ -47,8 +47,10 @@ def deprecate( raise RuntimeError(msg) elif when == 10: removed = "Pillow 10 (2023-07-01)" + elif when == 11: + removed = "Pillow 11 (2024-10-15)" else: - msg = f"Unknown removal version, update {__name__}?" + msg = f"Unknown removal version: {when}. Update {__name__}?" raise ValueError(msg) if replacement and action: