Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 6, 2022
1 parent 8750005 commit dcae026
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Tests/test_file_gimppalette.py
Expand Up @@ -23,6 +23,7 @@ def test_sanity():
def test_large_file_is_truncated():
import warnings
from unittest.mock import patch

try:
original_value = GimpPaletteFile._max_file_size
GimpPaletteFile._max_file_size = 100
Expand All @@ -35,6 +36,7 @@ def test_large_file_is_truncated():
finally:
GimpPaletteFile._max_file_size = original_value


def test_get_palette():
# Arrange
with open("Tests/images/custom_gimp_palette.gpl", "rb") as fp:
Expand Down
5 changes: 3 additions & 2 deletions src/PIL/GimpPaletteFile.py
Expand Up @@ -28,7 +28,7 @@ class GimpPaletteFile:
#: override if reading larger palettes is needed
max_colors = 256
_max_line_size = 100
_max_file_size = 2 ** 20
_max_file_size = 2**20

def __init__(self, fp):

Expand All @@ -47,7 +47,8 @@ def __init__(self, fp):
read += len(s)
if read >= self._max_file_size:
warnings.warn(
f"Palette file truncated at {self._max_file_size - len(s)} bytes")
f"Palette file truncated at {self._max_file_size - len(s)} bytes"
)
break

# skip fields and comment lines
Expand Down

0 comments on commit dcae026

Please sign in to comment.