Add in cherry-pick

This commit is contained in:
Frederick Price 2023-04-20 12:45:24 -04:00
parent 39a535fb0f
commit 411ff3322c
3 changed files with 19 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import io
from PIL import EpsImagePlugin, Image
import pytest
from .helper import PillowTestCase, hopper, unittest
@ -252,3 +253,17 @@ class TestFileEps(PillowTestCase):
self.assertEqual(image.mode, "RGB")
self.assertEqual(image.size, (460, 352))
self.assertEqual(image.format, "EPS")
@pytest.mark.timeout(timeout=5)
@pytest.mark.parametrize(
"test_file",
[
("Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps")
],
)
def test_timeout(test_file):
with open(test_file, "rb") as f:
with pytest.raises(Image.UnidentifiedImageError):
with Image.open(f):
pass

View File

@ -183,12 +183,12 @@ class PSFile(object):
self.fp.seek(offset, whence)
def readline(self):
s = self.char or b""
s = [self.char or b""]
self.char = None
c = self.fp.read(1)
while c not in b"\r\n":
s = s + c
while (c not in b"\r\n") and len(c):
s.append(c)
c = self.fp.read(1)
self.char = self.fp.read(1)
@ -196,7 +196,7 @@ class PSFile(object):
if self.char in b"\r\n":
self.char = None
return s.decode("latin-1")
return b"".join(s).decode("latin-1")
def _accept(prefix):