Skip to content

Commit

Permalink
Use bytes literals instead of bytes(str)
Browse files Browse the repository at this point in the history
Bytes literals are available on all supported Python versions. Rather
than convert strings literals to bytes at runtime, simply use a bytes
literal.
  • Loading branch information
jdufresne committed Oct 7, 2019
1 parent bbfa8bc commit 922f55c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
6 changes: 1 addition & 5 deletions Tests/check_icns_dos.py
Expand Up @@ -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"))
16 changes: 1 addition & 15 deletions Tests/check_j2k_dos.py
Expand Up @@ -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"))

0 comments on commit 922f55c

Please sign in to comment.