From 922f55c265773e631399233ff32aa13fa9d330a6 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 6 Oct 2019 19:26:55 -0700 Subject: [PATCH] Use bytes literals instead of bytes(str) Bytes literals are available on all supported Python versions. Rather than convert strings literals to bytes at runtime, simply use a bytes literal. --- Tests/check_icns_dos.py | 6 +----- Tests/check_j2k_dos.py | 16 +--------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/Tests/check_icns_dos.py b/Tests/check_icns_dos.py index 03eda2e3f..3f4fb6518 100644 --- a/Tests/check_icns_dos.py +++ b/Tests/check_icns_dos.py @@ -4,9 +4,5 @@ from io import BytesIO from PIL import Image -from PIL._util import py3 -if py3: - Image.open(BytesIO(bytes("icns\x00\x00\x00\x10hang\x00\x00\x00\x00", "latin-1"))) -else: - Image.open(BytesIO(bytes("icns\x00\x00\x00\x10hang\x00\x00\x00\x00"))) +Image.open(BytesIO(b"icns\x00\x00\x00\x10hang\x00\x00\x00\x00")) diff --git a/Tests/check_j2k_dos.py b/Tests/check_j2k_dos.py index 7d0e95a60..273c18585 100644 --- a/Tests/check_j2k_dos.py +++ b/Tests/check_j2k_dos.py @@ -4,19 +4,5 @@ from io import BytesIO from PIL import Image -from PIL._util import py3 -if py3: - Image.open( - BytesIO( - bytes( - "\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang", - "latin-1", - ) - ) - ) - -else: - Image.open( - BytesIO(bytes("\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang")) - ) +Image.open(BytesIO(b"\x00\x00\x00\x0cjP\x20\x20\x0d\x0a\x87\x0a\x00\x00\x00\x00hang"))