diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 1832e3e46..ddeded6fb 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -86,7 +86,7 @@ def test_32bit_plain_pgm(tmp_path): def test_plain_pbm_data_with_comments(tmp_path): path1 = str(tmp_path / "temp1.ppm") path2 = str(tmp_path / "temp2.ppm") - comment = b"# veeery long comment" * 10 ** 6 + comment = b"# veeery long comment" * 10**6 with open(path1, "wb") as f1, open(path2, "wb") as f2: f1.write(b"P1\n2 2\n\n1010") f2.write(b"P1\n2 2\n" + comment + b"\n1010" + comment) @@ -118,7 +118,7 @@ def test_plain_pbm_invalid_data(tmp_path): def test_plain_ppm_data_with_comments(tmp_path): path1 = str(tmp_path / "temp1.ppm") path2 = str(tmp_path / "temp2.ppm") - comment = b"# veeery long comment" * 10 ** 6 + comment = b"# veeery long comment" * 10**6 with open(path1, "wb") as f1, open(path2, "wb") as f2: f1.write(b"P3\n2 2\n255\n0 0 0 001 1 1 2 2 2 255 255 255") f2.write( diff --git a/src/PIL/PpmImagePlugin.py b/src/PIL/PpmImagePlugin.py index 9a5cac7d0..cae078d02 100644 --- a/src/PIL/PpmImagePlugin.py +++ b/src/PIL/PpmImagePlugin.py @@ -145,7 +145,7 @@ class PpmImageFile(ImageFile.ImageFile): class PpmPlainDecoder(ImageFile.PyDecoder): _pulls_fd = True - def _read_block(self, block_size=10 ** 6): + def _read_block(self, block_size=10**6): return bytearray(self.fd.read(block_size)) def _find_comment_end(self, block, start=0): @@ -218,9 +218,9 @@ class PpmPlainDecoder(ImageFile.PyDecoder): def _decode_blocks(self, channels=1, depth=8): decoded_data = bytearray() if depth == 32: - maxval = 2 ** 31 - 1 # HACK: 32-bit grayscale uses signed int + maxval = 2**31 - 1 # HACK: 32-bit grayscale uses signed int else: - maxval = 2 ** depth - 1 # FIXME: should be passed by _open + maxval = 2**depth - 1 # FIXME: should be passed by _open max_len = 10 bytes_per_sample = depth // 8 total_tokens = self.size * channels