From abe25b71914bca5a7d23a3316c6c8ce6da7a887f Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 1 Jul 2015 09:19:28 +1000 Subject: [PATCH] Rearranged format handler fetching --- PIL/Image.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index 141d1b264..62ae9b5ac 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1682,14 +1682,9 @@ class Image(object): ext = os.path.splitext(filename)[1].lower() if not format: - try: - format = EXTENSION[ext] - except KeyError: + if ext not in EXTENSION: init() - try: - format = EXTENSION[ext] - except KeyError: - raise KeyError(ext) # unknown extension + format = EXTENSION[ext] if format.upper() not in SAVE: init()