Skip to content

Commit

Permalink
Call startswith/endswith once with a tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Mar 3, 2025
1 parent e4cac21 commit a2b13cc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/PIL/IcnsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ def read_png_or_jpeg2000(
Image._decompression_bomb_check(im.size)
return {"RGBA": im}
elif (
sig.startswith(b"\xff\x4f\xff\x51")
or sig.startswith(b"\x0d\x0a\x87\x0a")
sig.startswith((b"\xff\x4f\xff\x51", b"\x0d\x0a\x87\x0a"))
or sig == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a"
):
if not enable_jpeg2k:
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ def _setup(self) -> None:
# byte order.
elif rawmode == "I;16":
rawmode = "I;16N"
elif rawmode.endswith(";16B") or rawmode.endswith(";16L"):
elif rawmode.endswith((";16B", ";16L")):
rawmode = rawmode[:-1] + "N"

# Offset in the tile tuple is 0, we go from 0,0 to
Expand Down

0 comments on commit a2b13cc

Please sign in to comment.