From 955f6848fd6c62ca3fa9ad383ebd7e82b8aa1bdf Mon Sep 17 00:00:00 2001 From: ces42 Date: Mon, 13 Feb 2017 18:06:26 +0100 Subject: [PATCH] more explicit error message when saving to a file with invalid extension --- PIL/Image.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PIL/Image.py b/PIL/Image.py index ed1d10907..c643e24d9 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1715,7 +1715,10 @@ class Image(object): if not format: if ext not in EXTENSION: init() - format = EXTENSION[ext] + try: + format = EXTENSION[ext] + except KeyError: + raise ValueError('unknown file extension: {}'.format(ext)) if format.upper() not in SAVE: init()