Remove redundant bytearray

This commit is contained in:
Hugo 2019-10-07 15:40:00 +03:00
parent 865b17d5cf
commit 4382413bb4
3 changed files with 9 additions and 11 deletions

View File

@ -71,9 +71,7 @@ class TestFileGif(PillowTestCase):
def check(colors, size, expected_palette_length):
# make an image with empty colors in the start of the palette range
im = Image.frombytes(
"P",
(colors, colors),
bytes(bytearray(range(256 - colors, 256)) * colors),
"P", (colors, colors), bytes(range(256 - colors, 256)) * colors
)
im = im.resize((size, size))
outfile = BytesIO()
@ -103,7 +101,7 @@ class TestFileGif(PillowTestCase):
check(256, 511, 256)
def test_optimize_full_l(self):
im = Image.frombytes("L", (16, 16), bytes(bytearray(range(256))))
im = Image.frombytes("L", (16, 16), bytes(range(256)))
test_file = BytesIO()
im.save(test_file, "GIF", optimize=True)
self.assertEqual(im.mode, "L")
@ -632,7 +630,7 @@ class TestFileGif(PillowTestCase):
# that's > 128 items where the transparent color is actually
# the top palette entry to trigger the bug.
data = bytes(bytearray(range(1, 254)))
data = bytes(range(1, 254))
palette = ImagePalette.ImagePalette("RGB", list(range(256)) * 3)
im = Image.new("L", (253, 1))
@ -680,7 +678,7 @@ class TestFileGif(PillowTestCase):
im = hopper("P")
im_l = Image.frombytes("L", im.size, im.tobytes())
palette = bytes(bytearray(im.getpalette()))
palette = bytes(im.getpalette())
out = self.tempfile("temp.gif")
im_l.save(out, palette=palette)
@ -695,7 +693,7 @@ class TestFileGif(PillowTestCase):
# Forcing a non-straight grayscale palette.
im = hopper("P")
palette = bytes(bytearray([255 - i // 3 for i in range(768)]))
palette = bytes([255 - i // 3 for i in range(768)])
out = self.tempfile("temp.gif")
im.save(out, palette=palette)
@ -736,7 +734,7 @@ class TestFileGif(PillowTestCase):
im.putpalette(ImagePalette.ImagePalette("RGB"))
im.info = {"background": 0}
passed_palette = bytes(bytearray([255 - i // 3 for i in range(768)]))
passed_palette = bytes([255 - i // 3 for i in range(768)])
GifImagePlugin._FORCE_OPTIMIZE = True
try:

View File

@ -18,7 +18,7 @@ class TestLibPack(PillowTestCase):
if isinstance(data, int):
data_len = data * len(pixels)
data = bytes(bytearray(range(1, data_len + 1)))
data = bytes(range(1, data_len + 1))
self.assertEqual(data, im.tobytes("raw", rawmode))
@ -226,7 +226,7 @@ class TestLibUnpack(PillowTestCase):
"""
if isinstance(data, int):
data_len = data * len(pixels)
data = bytes(bytearray(range(1, data_len + 1)))
data = bytes(range(1, data_len + 1))
im = Image.frombytes(mode, (len(pixels), 1), data, "raw", rawmode, 0, 1)

View File

@ -1742,7 +1742,7 @@ class AppendingTiffWriter:
# pad to 16 byte boundary
padBytes = 16 - pos % 16
if 0 < padBytes < 16:
self.f.write(bytes(bytearray(padBytes)))
self.f.write(bytes(padBytes))
self.offsetOfNewPage = self.f.tell()
def setEndian(self, endian):