more explicit error message when saving to a file with invalid extension

This commit is contained in:
ces42 2017-02-13 18:06:26 +01:00 committed by GitHub
parent 0f9233623e
commit 955f6848fd

View File

@ -1715,7 +1715,10 @@ class Image(object):
if not format: if not format:
if ext not in EXTENSION: if ext not in EXTENSION:
init() init()
format = EXTENSION[ext] try:
format = EXTENSION[ext]
except KeyError:
raise ValueError('unknown file extension: {}'.format(ext))
if format.upper() not in SAVE: if format.upper() not in SAVE:
init() init()