mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Use an import error instead of a plain exception
This commit is contained in:
parent
ab3687e10f
commit
8ca2cfe75c
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user