From 8ca2cfe75c01ca17bf94e1f715f376c312e8f646 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 3 Apr 2014 16:05:02 -0700 Subject: [PATCH] Use an import error instead of a plain exception --- PIL/ImageCms.py | 4 ++-- PIL/_util.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PIL/ImageCms.py b/PIL/ImageCms.py index ec891d0e5..c875712c1 100644 --- a/PIL/ImageCms.py +++ b/PIL/ImageCms.py @@ -86,11 +86,11 @@ VERSION = "1.0.0 pil" from PIL import Image try: from PIL import _imagingcms -except ImportError: +except ImportError as ex: # Allow error import for doc purposes, but error out when accessing # anything in core. from _util import import_err - _imagingcms = import_err('ImagingCMS') + _imagingcms = import_err(ex) from PIL._util import isStringType core = _imagingcms diff --git a/PIL/_util.py b/PIL/_util.py index e1ede1217..761c258f1 100644 --- a/PIL/_util.py +++ b/PIL/_util.py @@ -16,7 +16,7 @@ def isDirectory(f): return isPath(f) and os.path.isdir(f) class import_err(object): - def __init__(self, name=''): - self.name = name + def __init__(self, ex): + self.ex = ex def __getattr__(self, elt): - raise Exception("Import Error, %s not available" % self.name) + raise self.ex