Use an import error instead of a plain exception

This commit is contained in:
wiredfool 2014-04-03 16:05:02 -07:00
parent ab3687e10f
commit 8ca2cfe75c
2 changed files with 5 additions and 5 deletions

View File

@ -86,11 +86,11 @@ VERSION = "1.0.0 pil"
from PIL import Image from PIL import Image
try: try:
from PIL import _imagingcms from PIL import _imagingcms
except ImportError: except ImportError as ex:
# Allow error import for doc purposes, but error out when accessing # Allow error import for doc purposes, but error out when accessing
# anything in core. # anything in core.
from _util import import_err from _util import import_err
_imagingcms = import_err('ImagingCMS') _imagingcms = import_err(ex)
from PIL._util import isStringType from PIL._util import isStringType
core = _imagingcms core = _imagingcms

View File

@ -16,7 +16,7 @@ def isDirectory(f):
return isPath(f) and os.path.isdir(f) return isPath(f) and os.path.isdir(f)
class import_err(object): class import_err(object):
def __init__(self, name=''): def __init__(self, ex):
self.name = name self.ex = ex
def __getattr__(self, elt): def __getattr__(self, elt):
raise Exception("Import Error, %s not available" % self.name) raise self.ex