Skip to content

Commit

Permalink
Fix to ensure that define is interpreted as a string on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredfool committed Jun 21, 2017
1 parent 67d6e00 commit edc8d86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion PIL/Image.py
Expand Up @@ -56,7 +56,10 @@ def __getattr__(self, id):
from . 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")
"version of Pillow or PIL: Core Version: %s"
"Pillow Version: %s" %
(getattr(core, 'PILLOW_VERSION', None),
PILLOW_VERSION))

except ImportError as v:
core = _imaging_not_installed()
Expand Down
3 changes: 2 additions & 1 deletion _imaging.c
Expand Up @@ -3435,6 +3435,7 @@ static PyMethodDef functions[] = {
static int
setup_module(PyObject* m) {
PyObject* d = PyModule_GetDict(m);
const char* version = (char*)PILLOW_VERSION;

/* Ready object types */
if (PyType_Ready(&Imaging_Type) < 0)
Expand Down Expand Up @@ -3479,7 +3480,7 @@ setup_module(PyObject* m) {
}
#endif

PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(PILLOW_VERSION));
PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(version));

return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Expand Up @@ -584,7 +584,10 @@ def build_extensions(self):
if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
defs.append(("WORDS_BIGENDIAN", None))

defs.append(("PILLOW_VERSION", '"%s"'%PILLOW_VERSION))
if sys.platform == "win32":
defs.append(("PILLOW_VERSION", '"\\"%s\\""'%PILLOW_VERSION))
else:
defs.append(("PILLOW_VERSION", '"%s"'%PILLOW_VERSION))

exts = [(Extension("PIL._imaging",
files,
Expand Down

0 comments on commit edc8d86

Please sign in to comment.