Skip to content

Commit

Permalink
Merge pull request #1016 from wiredfool/port-docs
Browse files Browse the repository at this point in the history
Better docs explaining import _imaging failure
  • Loading branch information
hugovk committed Nov 19, 2014
2 parents e0b94d6 + b13a904 commit 81bb6df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def __getattr__(self, id):
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 "
Expand Down Expand Up @@ -91,6 +92,7 @@ def __getattr__(self, id):
RuntimeWarning
)
# Fail here anyway. Don't let people run with a mostly broken Pillow.
# see docs/porting-pil-to-pillow.rst
raise

try:
Expand Down
4 changes: 4 additions & 0 deletions docs/porting-pil-to-pillow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 81bb6df

Please sign in to comment.