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.
This commit is contained in:
Jon Dufresne 2019-10-06 19:26:55 -07:00
parent bbfa8bc1ca
commit 922f55c265
2 changed files with 2 additions and 20 deletions

View File

@ -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"))

View File

@ -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"))