basic sanity check that the version of the _imaging.c and Image.py files are the same

This commit is contained in:
wiredfool 2013-04-08 21:43:15 -07:00
parent 7f698a6fc5
commit 088c752e40
2 changed files with 11 additions and 0 deletions

View File

@ -27,6 +27,7 @@
from __future__ import print_function
VERSION = "1.1.7"
PILLOW_VERSION = "2.0.0"
try:
import warnings
@ -54,6 +55,11 @@ try:
# them. Note that other modules should not refer to _imaging
# directly; import Image and use the Image.core variable instead.
from PIL import _imaging as core
if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
" version of Pillow or PIL. Most PIL functions "
" will be disabled ")
except ImportError as v:
core = _imaging_not_installed()
if str(v)[:20] == "Module use of python" and warnings:
@ -65,6 +71,8 @@ except ImportError as v:
"of Python; most PIL functions will be disabled",
RuntimeWarning
)
if str(v).startswith("The _imaging extension") and warnings:
warnings.warn(str(v), RuntimeWarning)
try:
import builtins

View File

@ -71,6 +71,7 @@
* See the README file for information on usage and redistribution.
*/
#define PILLOW_VERSION "2.0.0"
#include "Python.h"
@ -3431,6 +3432,8 @@ setup_module(PyObject* m) {
}
#endif
PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(PILLOW_VERSION));
return 0;
}