Skip to content

Commit

Permalink
deprecate EpsImagePlugin.PSFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Feb 6, 2023
1 parent be9aea3 commit bd0fac8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Tests/test_file_eps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -346,6 +347,11 @@ def _test_readline_file_psfile(test_string, 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(
"line_ending",
Expand Down
10 changes: 10 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===================================================== ============================================================
Expand Down
11 changes: 11 additions & 0 deletions docs/releasenotes/9.4.0.rst
Original file line number Diff line number Diff line change
@@ -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
=============

Expand Down
6 changes: 6 additions & 0 deletions src/PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from . import Image, ImageFile
from ._binary import i32le as i32
from ._deprecate import deprecate

#
# --------------------------------------------------------------------
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/PIL/_deprecate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bd0fac8

Please sign in to comment.