diff --git a/Tests/test_file_eps.py b/Tests/test_file_eps.py index 1c21aa8ca..3181fc204 100644 --- a/Tests/test_file_eps.py +++ b/Tests/test_file_eps.py @@ -329,46 +329,6 @@ def test_read_binary_preview() -> None: pass -def test_readline_psfile(tmp_path: Path) -> None: - # check all the freaking line endings possible from the spec - # test_string = u'something\r\nelse\n\rbaz\rbif\n' - line_endings = ["\r\n", "\n", "\n\r", "\r"] - strings = ["something", "else", "baz", "bif"] - - def _test_readline(t: EpsImagePlugin.PSFile, ending: str) -> None: - ending = f"Failure with line ending: {''.join(str(ord(s)) for s in ending)}" - assert t.readline().strip("\r\n") == "something", ending - assert t.readline().strip("\r\n") == "else", ending - assert t.readline().strip("\r\n") == "baz", ending - assert t.readline().strip("\r\n") == "bif", ending - - def _test_readline_io_psfile(test_string: str, ending: str) -> None: - f = io.BytesIO(test_string.encode("latin-1")) - with pytest.warns(DeprecationWarning): - t = EpsImagePlugin.PSFile(f) - _test_readline(t, ending) - - def _test_readline_file_psfile(test_string: str, ending: str) -> None: - f = str(tmp_path / "temp.txt") - with open(f, "wb") as w: - w.write(test_string.encode("latin-1")) - - with open(f, "rb") as r: - with pytest.warns(DeprecationWarning): - t = EpsImagePlugin.PSFile(r) - _test_readline(t, ending) - - for ending in line_endings: - s = ending.join(strings) - _test_readline_io_psfile(s, ending) - _test_readline_file_psfile(s, ending) - - -def test_psfile_deprecation() -> None: - 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 0f996a94b..b7c15ff63 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -12,16 +12,6 @@ Deprecated features Below are features which are considered deprecated. Where appropriate, a :py:exc:`DeprecationWarning` is issued. -PSFile -~~~~~~ - -.. deprecated:: 9.5.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. - PyAccess and Image.USE_CFFI_ACCESS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -137,6 +127,17 @@ Removed features Deprecated features are only removed in major releases after an appropriate period of deprecation has passed. +PSFile +~~~~~~ + +.. deprecated:: 9.5.0 +.. versionremoved:: 11.0.0 + +The :py:class:`!PSFile` class was 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. + Tk/Tcl 8.4 ~~~~~~~~~~ diff --git a/docs/releasenotes/11.0.0.rst b/docs/releasenotes/11.0.0.rst new file mode 100644 index 000000000..e04ae9fd6 --- /dev/null +++ b/docs/releasenotes/11.0.0.rst @@ -0,0 +1,58 @@ +11.0.0 +------ + +Security +======== + +TODO +^^^^ + +TODO + +:cve:`YYYY-XXXXX`: TODO +^^^^^^^^^^^^^^^^^^^^^^^ + +TODO + +Backwards Incompatible Changes +============================== + +PSFile +^^^^^^ + +The :py:class:`!PSFile` class was 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. + +Deprecations +============ + +TODO +^^^^ + +TODO + +API Changes +=========== + +TODO +^^^^ + +TODO + +API Additions +============= + +TODO +^^^^ + +TODO + +Other Changes +============= + +TODO +^^^^ + +TODO diff --git a/docs/releasenotes/9.5.0.rst b/docs/releasenotes/9.5.0.rst index 08e9ec2a4..501479bb6 100644 --- a/docs/releasenotes/9.5.0.rst +++ b/docs/releasenotes/9.5.0.rst @@ -32,7 +32,7 @@ Deprecations PSFile ^^^^^^ -The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will +The :py:class:`!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. diff --git a/docs/releasenotes/index.rst b/docs/releasenotes/index.rst index 6ee5fb6c8..641cda4ef 100644 --- a/docs/releasenotes/index.rst +++ b/docs/releasenotes/index.rst @@ -14,6 +14,7 @@ expected to be backported to earlier versions. .. toctree:: :maxdepth: 2 + 11.0.0 10.4.0 10.3.0 10.2.0 diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py index f31b1c1a2..71e869045 100644 --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -31,7 +31,6 @@ from typing import IO from . import Image, ImageFile from ._binary import i32le as i32 -from ._deprecate import deprecate # -------------------------------------------------------------------- @@ -159,43 +158,6 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False): return im -class PSFile: - """ - Wrapper for bytesio object that treats either CR or LF as end of line. - This class is no longer used internally, but kept for backwards compatibility. - """ - - 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 - - def seek(self, offset, whence=io.SEEK_SET): - self.char = None - self.fp.seek(offset, whence) - - def readline(self) -> str: - s = [self.char or b""] - self.char = None - - c = self.fp.read(1) - while (c not in b"\r\n") and len(c): - s.append(c) - c = self.fp.read(1) - - self.char = self.fp.read(1) - # line endings can be 1 or 2 of \r \n, in either order - if self.char in b"\r\n": - self.char = None - - return b"".join(s).decode("latin-1") - - def _accept(prefix: bytes) -> bool: return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)