Skip to content

Commit

Permalink
Review, typos and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Apr 1, 2021
1 parent fea4196 commit 8febdad
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Tests/test_file_blp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PIL import Image
import pytest

from PIL import Image

from .helper import assert_image_equal_tofile


Expand Down
5 changes: 2 additions & 3 deletions Tests/test_file_eps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io

import pytest

from PIL import EpsImagePlugin, Image, features
Expand Down Expand Up @@ -268,9 +269,7 @@ def test_emptyline():
@pytest.mark.timeout(timeout=5)
@pytest.mark.parametrize(
"test_file",
[
("Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps")
],
["Tests/images/timeout-d675703545fee17acab56e5fec644c19979175de.eps"],
)
def test_timeout(test_file):
with open(test_file, "rb") as f:
Expand Down
11 changes: 9 additions & 2 deletions Tests/test_file_psd.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,18 @@ def test_combined_larger_than_size():
with Image.open("Tests/images/combined_larger_than_size.psd"):
pass


@pytest.mark.parametrize(
"test_file,raises",
[
("Tests/images/timeout-1ee28a249896e05b83840ae8140622de8e648ba9.psd", Image.UnidentifiedImageError),
("Tests/images/timeout-598843abc37fc080ec36a2699ebbd44f795d3a6f.psd", Image.UnidentifiedImageError),
(
"Tests/images/timeout-1ee28a249896e05b83840ae8140622de8e648ba9.psd",
Image.UnidentifiedImageError,
),
(
"Tests/images/timeout-598843abc37fc080ec36a2699ebbd44f795d3a6f.psd",
Image.UnidentifiedImageError,
),
("Tests/images/timeout-c8efc3fded6426986ba867a399791bae544f59bc.psd", OSError),
("Tests/images/timeout-dedc7a4ebd856d79b4359bbcc79e8ef231ce38f6.psd", OSError),
],
Expand Down
5 changes: 2 additions & 3 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,11 @@ def test_close_on_load_nonexclusive(self, tmp_path):
)
def test_string_dimension(self):
# Assert that an error is raised if one of the dimensions is a string
with pytest.raises(OSError):
with Image.open("Tests/images/string_dimension.tiff") as im:
with Image.open("Tests/images/string_dimension.tiff") as im:
with pytest.raises(OSError):
im.load()



@pytest.mark.skipif(not is_win32(), reason="Windows only")
class TestFileTiffW32:
def test_fd_leak(self, tmp_path):
Expand Down
4 changes: 1 addition & 3 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def _safe_read(fp, size):
:param size: Number of bytes to read.
:returns: A string containing <i>size</i> bytes of data.
Raises an OSError if the file is truncated and the read can not be completed
Raises an OSError if the file is truncated and the read cannot be completed
"""
if size <= 0:
Expand All @@ -569,8 +569,6 @@ def _safe_read(fp, size):
return b"".join(data)




class PyCodecState:
def __init__(self):
self.xsize = 0
Expand Down
1 change: 1 addition & 0 deletions src/PIL/PsdImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def _close__fp(self):
finally:
self.__fp = None


def _layerinfo(fp, ct_bytes):
# read layerinfo block
layers = []
Expand Down
2 changes: 1 addition & 1 deletion src/libImaging/FliDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t byt
}
advance = I32(ptr);
if (advance == 0 ) {
// If there's no advance, we're in in infinite loop
// If there's no advance, we're in an infinite loop
state->errcode = IMAGING_CODEC_BROKEN;
return -1;
}
Expand Down

0 comments on commit 8febdad

Please sign in to comment.