Skip to content

Commit 2a660bb

Browse files
committed
Remove PSFile class, deprecated in Pillow 9.5.0
1 parent 9b4fae7 commit 2a660bb

File tree

6 files changed

+71
-89
lines changed

6 files changed

+71
-89
lines changed

Tests/test_file_eps.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -329,46 +329,6 @@ def test_read_binary_preview() -> None:
329329
pass
330330

331331

332-
def test_readline_psfile(tmp_path: Path) -> None:
333-
# check all the freaking line endings possible from the spec
334-
# test_string = u'something\r\nelse\n\rbaz\rbif\n'
335-
line_endings = ["\r\n", "\n", "\n\r", "\r"]
336-
strings = ["something", "else", "baz", "bif"]
337-
338-
def _test_readline(t: EpsImagePlugin.PSFile, ending: str) -> None:
339-
ending = f"Failure with line ending: {''.join(str(ord(s)) for s in ending)}"
340-
assert t.readline().strip("\r\n") == "something", ending
341-
assert t.readline().strip("\r\n") == "else", ending
342-
assert t.readline().strip("\r\n") == "baz", ending
343-
assert t.readline().strip("\r\n") == "bif", ending
344-
345-
def _test_readline_io_psfile(test_string: str, ending: str) -> None:
346-
f = io.BytesIO(test_string.encode("latin-1"))
347-
with pytest.warns(DeprecationWarning):
348-
t = EpsImagePlugin.PSFile(f)
349-
_test_readline(t, ending)
350-
351-
def _test_readline_file_psfile(test_string: str, ending: str) -> None:
352-
f = str(tmp_path / "temp.txt")
353-
with open(f, "wb") as w:
354-
w.write(test_string.encode("latin-1"))
355-
356-
with open(f, "rb") as r:
357-
with pytest.warns(DeprecationWarning):
358-
t = EpsImagePlugin.PSFile(r)
359-
_test_readline(t, ending)
360-
361-
for ending in line_endings:
362-
s = ending.join(strings)
363-
_test_readline_io_psfile(s, ending)
364-
_test_readline_file_psfile(s, ending)
365-
366-
367-
def test_psfile_deprecation() -> None:
368-
with pytest.warns(DeprecationWarning):
369-
EpsImagePlugin.PSFile(None)
370-
371-
372332
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
373333
@pytest.mark.parametrize(
374334
"line_ending",

docs/deprecations.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ Deprecated features
1212
Below are features which are considered deprecated. Where appropriate,
1313
a :py:exc:`DeprecationWarning` is issued.
1414

15-
PSFile
16-
~~~~~~
17-
18-
.. deprecated:: 9.5.0
19-
20-
The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will
21-
be removed in Pillow 11 (2024-10-15). This class was only made as a helper to
22-
be used internally, so there is no replacement. If you need this functionality
23-
though, it is a very short class that can easily be recreated in your own code.
24-
2515
PyAccess and Image.USE_CFFI_ACCESS
2616
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2717

@@ -137,6 +127,17 @@ Removed features
137127
Deprecated features are only removed in major releases after an appropriate
138128
period of deprecation has passed.
139129

130+
PSFile
131+
~~~~~~
132+
133+
.. deprecated:: 9.5.0
134+
.. versionremoved:: 11.0.0
135+
136+
The :py:class:`!PSFile` class was removed in Pillow 11 (2024-10-15).
137+
This class was only made as a helper to be used internally,
138+
so there is no replacement. If you need this functionality though,
139+
it is a very short class that can easily be recreated in your own code.
140+
140141
Tk/Tcl 8.4
141142
~~~~~~~~~~
142143

docs/releasenotes/11.0.0.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
11.0.0
2+
------
3+
4+
Security
5+
========
6+
7+
TODO
8+
^^^^
9+
10+
TODO
11+
12+
:cve:`YYYY-XXXXX`: TODO
13+
^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
TODO
16+
17+
Backwards Incompatible Changes
18+
==============================
19+
20+
PSFile
21+
^^^^^^
22+
23+
The :py:class:`!PSFile` class was removed in Pillow 11 (2024-10-15).
24+
This class was only made as a helper to be used internally,
25+
so there is no replacement. If you need this functionality though,
26+
it is a very short class that can easily be recreated in your own code.
27+
28+
Deprecations
29+
============
30+
31+
TODO
32+
^^^^
33+
34+
TODO
35+
36+
API Changes
37+
===========
38+
39+
TODO
40+
^^^^
41+
42+
TODO
43+
44+
API Additions
45+
=============
46+
47+
TODO
48+
^^^^
49+
50+
TODO
51+
52+
Other Changes
53+
=============
54+
55+
TODO
56+
^^^^
57+
58+
TODO

docs/releasenotes/9.5.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Deprecations
3232
PSFile
3333
^^^^^^
3434

35-
The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will
35+
The :py:class:`!PSFile` class has been deprecated and will
3636
be removed in Pillow 11 (2024-10-15). This class was only made as a helper to
3737
be used internally, so there is no replacement. If you need this functionality
3838
though, it is a very short class that can easily be recreated in your own code.

docs/releasenotes/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ expected to be backported to earlier versions.
1414
.. toctree::
1515
:maxdepth: 2
1616

17+
11.0.0
1718
10.4.0
1819
10.3.0
1920
10.2.0

src/PIL/EpsImagePlugin.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
from . import Image, ImageFile
3333
from ._binary import i32le as i32
34-
from ._deprecate import deprecate
3534

3635
# --------------------------------------------------------------------
3736

@@ -159,43 +158,6 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
159158
return im
160159

161160

162-
class PSFile:
163-
"""
164-
Wrapper for bytesio object that treats either CR or LF as end of line.
165-
This class is no longer used internally, but kept for backwards compatibility.
166-
"""
167-
168-
def __init__(self, fp):
169-
deprecate(
170-
"PSFile",
171-
11,
172-
action="If you need the functionality of this class "
173-
"you will need to implement it yourself.",
174-
)
175-
self.fp = fp
176-
self.char = None
177-
178-
def seek(self, offset, whence=io.SEEK_SET):
179-
self.char = None
180-
self.fp.seek(offset, whence)
181-
182-
def readline(self) -> str:
183-
s = [self.char or b""]
184-
self.char = None
185-
186-
c = self.fp.read(1)
187-
while (c not in b"\r\n") and len(c):
188-
s.append(c)
189-
c = self.fp.read(1)
190-
191-
self.char = self.fp.read(1)
192-
# line endings can be 1 or 2 of \r \n, in either order
193-
if self.char in b"\r\n":
194-
self.char = None
195-
196-
return b"".join(s).decode("latin-1")
197-
198-
199161
def _accept(prefix: bytes) -> bool:
200162
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
201163

0 commit comments

Comments
 (0)