mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +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
|
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user