From bf0abdca27cd84dafd185bd44206c82b5c14330d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 19 Jan 2023 08:06:30 +1100 Subject: [PATCH] Do not retry past formats when loading all formats for the first time --- src/PIL/Image.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 7fc8f496eeb..833473f789d 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -3268,8 +3268,14 @@ def _open_core(fp, filename, prefix, formats): im = _open_core(fp, filename, prefix, formats) if im is None and formats is ID: + checked_formats = formats.copy() if init(): - im = _open_core(fp, filename, prefix, formats) + im = _open_core( + fp, + filename, + prefix, + tuple(format for format in formats if format not in checked_formats), + ) if im: im._exclusive_fp = exclusive_fp