Skip to content

Commit ae7448e

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 312d399 commit ae7448e

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
@@ -434,12 +434,14 @@ def _getdecoder(
434434
elif not isinstance(args, tuple):
435435
args = (args,)
436436

437-
if decoder_name == "raw" and args[0] in _DEPRECATED_RAWMODES:
438-
deprecate(
439-
f"rawmode {args[0]}",
440-
12,
441-
replacement=f"rawmode {_DEPRECATED_RAWMODES[args[0]]}",
442-
)
437+
if decoder_name == "raw":
438+
rawmode = args[0]
439+
if mode != rawmode and rawmode in _DEPRECATED_RAWMODES:
440+
deprecate(
441+
f"rawmode {rawmode}",
442+
12,
443+
replacement=f"rawmode {_DEPRECATED_RAWMODES[rawmode]}",
444+
)
443445

444446
try:
445447
decoder = DECODERS[decoder_name]

0 commit comments

Comments
 (0)