Skip to content

Commit 79d5f38

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 c4c72f5 commit 79d5f38

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

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

442444
try:
443445
decoder = DECODERS[decoder_name]

0 commit comments

Comments
 (0)