From b13a90441fbc56dd7cd06191446e54d89fb3716c Mon Sep 17 00:00:00 2001 From: wiredfool Date: Wed, 19 Nov 2014 11:41:46 -0800 Subject: [PATCH] Better docs explaining import _imaging failure [ci skip] --- PIL/Image.py | 10 ++++++---- docs/porting-pil-to-pillow.rst | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index 922fe36a8..d556df34c 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -55,10 +55,11 @@ except ImportError: pass try: - # If the _imaging C module is not present, you can still use - # the "open" function to identify files, but you cannot load - # them. Note that other modules should not refer to _imaging - # directly; import Image and use the Image.core variable instead. + # If the _imaging C module is not present, Pillow will not load. + # Note that other modules should not refer to _imaging directly; + # import Image and use the Image.core variable instead. + # Also note that Image.core is not a publicly documented interface, + # and should be considered private and subject to change. from PIL import _imaging as core if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None): raise ImportError("The _imaging extension was built for another " @@ -91,6 +92,7 @@ except ImportError as v: RuntimeWarning ) # Fail here anyway. Don't let people run with a mostly broken Pillow. + # see docs/porting-pil-to-pillow.rst raise try: diff --git a/docs/porting-pil-to-pillow.rst b/docs/porting-pil-to-pillow.rst index 88a6768e9..7ad781186 100644 --- a/docs/porting-pil-to-pillow.rst +++ b/docs/porting-pil-to-pillow.rst @@ -21,3 +21,7 @@ automatically imports any file in the Python path with a name ending in :file:`ImagePlugin.py`. You will need to import your image plugin manually. +Pillow will raise an exception if the core extension can't be loaded +for any reason, including a version mismatch between the Python and +extension code. Previously PIL allowed Python only code to run if the +core extension was not available.