Merge pull request #5250 from Piolie/open_formats_case

Changed Image.open formats parameter to be case-insensitive
This commit is contained in:
Andrew Murray 2021-02-08 18:19:02 +11:00 committed by GitHub
commit bc0c0cb11a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -94,7 +94,7 @@ class TestImage:
with pytest.raises(TypeError):
Image.open(PNGFILE, formats=123)
for formats in [["JPEG"], ("JPEG",)]:
for formats in [["JPEG"], ("JPEG",), ["jpeg"], ["Jpeg"], ["jPeG"], ["JpEg"]]:
with pytest.raises(UnidentifiedImageError):
Image.open(PNGFILE, formats=formats)

View File

@ -2922,6 +2922,7 @@ def open(fp, mode="r", formats=None):
def _open_core(fp, filename, prefix, formats):
for i in formats:
i = i.upper()
if i not in OPEN:
init()
try: