Skip to content

Commit b74ff65

Browse files
committed
don't show rawmode deprecation warning if mode is same as rawmode
The "BGR;15" and "BGR;16" modes being deprecated is separate from the "BGR;15" and "BGR;16" rawmodes being deprecated.
1 parent b5308fe commit b74ff65

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/PIL/Image.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,14 @@ def _getdecoder(
441441
elif not isinstance(args, tuple):
442442
args = (args,)
443443

444-
if decoder_name == "raw" and args[0] in _DEPRECATED_RAWMODES:
445-
deprecate(
446-
f"rawmode {args[0]}",
447-
12,
448-
replacement=f"rawmode {_DEPRECATED_RAWMODES[args[0]]}",
449-
)
444+
if decoder_name == "raw":
445+
rawmode = args[0]
446+
if mode != rawmode and rawmode in _DEPRECATED_RAWMODES:
447+
deprecate(
448+
f"rawmode {rawmode}",
449+
12,
450+
replacement=f"rawmode {_DEPRECATED_RAWMODES[rawmode]}",
451+
)
450452

451453
try:
452454
decoder = DECODERS[decoder_name]

0 commit comments

Comments
 (0)