From 79d5f38388cf1552d819f567d152376aa8301123 Mon Sep 17 00:00:00 2001 From: Yay295 Date: Sat, 22 Jun 2024 10:23:25 -0500 Subject: [PATCH] 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. --- src/PIL/Image.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 515c9e84f20..ba831156c5b 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -432,12 +432,14 @@ def _getdecoder( elif not isinstance(args, tuple): args = (args,) - if decoder_name == "raw" and args[0] in _DEPRECATED_RAWMODES: - deprecate( - f"rawmode {args[0]}", - 12, - replacement=f"rawmode {_DEPRECATED_RAWMODES[args[0]]}", - ) + if decoder_name == "raw": + rawmode = args[0] + if mode != rawmode and rawmode in _DEPRECATED_RAWMODES: + deprecate( + f"rawmode {rawmode}", + 12, + replacement=f"rawmode {_DEPRECATED_RAWMODES[rawmode]}", + ) try: decoder = DECODERS[decoder_name]