Skip to content

Commit

Permalink
Merge pull request #5250 from Piolie/open_formats_case
Browse files Browse the repository at this point in the history
Changed Image.open formats parameter to be case-insensitive
  • Loading branch information
radarhere committed Feb 8, 2021
2 parents 114ab4c + 957cc1b commit bc0c0cb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Tests/test_image.py
Expand Up @@ -94,7 +94,7 @@ def test_open_formats(self):
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)

Expand Down
1 change: 1 addition & 0 deletions src/PIL/Image.py
Expand Up @@ -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:
Expand Down

0 comments on commit bc0c0cb

Please sign in to comment.