From d06072ff467abac16973ddab4189587aad770ca4 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sat, 5 Jul 2014 14:30:34 -0700 Subject: [PATCH 1/5] Multiplication needs to be 64bit, to handle overflow regardless of the bittedness of the machine, fixes #771# --- libImaging/Storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libImaging/Storage.c b/libImaging/Storage.c index d31db5cb2..c6d2e5c5e 100644 --- a/libImaging/Storage.c +++ b/libImaging/Storage.c @@ -379,7 +379,7 @@ ImagingNew(const char* mode, int xsize, int ysize) } else bytes = strlen(mode); /* close enough */ - if ((Py_ssize_t) xsize * ysize * bytes <= THRESHOLD) { + if ((int64_t) xsize * (int64_t) ysize * bytes <= THRESHOLD) { im = ImagingNewBlock(mode, xsize, ysize); if (im) return im; From 07c68e2d6879544f4356887e8222dc3bc96fae15 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Sat, 5 Jul 2014 15:06:17 -0700 Subject: [PATCH 2/5] Windows compatibility --- libImaging/ImPlatform.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libImaging/ImPlatform.h b/libImaging/ImPlatform.h index be1f20f3f..70ee63119 100644 --- a/libImaging/ImPlatform.h +++ b/libImaging/ImPlatform.h @@ -69,4 +69,6 @@ #define FLOAT32 float #define FLOAT64 double - +#ifdef _MSC_VER +typedef signed __int64 int64_t; +#endif From fb51604296c83b26bd2cfca632a1a017d1ed06a2 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Wed, 9 Jul 2014 10:12:43 -0700 Subject: [PATCH 3/5] Don't install mp_compile if multiprocessing.Pool() fails, or if 1 process is going to be used --- mp_compile.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/mp_compile.py b/mp_compile.py index 71b4089e1..b7c3e7ce4 100644 --- a/mp_compile.py +++ b/mp_compile.py @@ -5,6 +5,11 @@ from multiprocessing import Pool, cpu_count from distutils.ccompiler import CCompiler import os +try: + MAX_PROCS = int(os.environ.get('MAX_CONCURRENCY', cpu_count())) +except: + MAX_PROCS = None + # hideous monkeypatching. but. but. but. def _mp_compile_one(tp): @@ -31,22 +36,27 @@ def _mp_compile(self, sources, output_dir=None, macros=None, output_dir, macros, include_dirs, sources, depends, extra_postargs) cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) - try: - max_procs = int(os.environ.get('MAX_CONCURRENCY', cpu_count())) - except: - max_procs = None - pool = Pool(max_procs) + pool = Pool(MAX_PROCS) try: print ("Building using %d processes" % pool._processes) except: pass - arr = [ - (self, obj, build, cc_args, extra_postargs, pp_opts) for obj in objects - ] + arr = [(self, obj, build, cc_args, extra_postargs, pp_opts) + for obj in objects] pool.map_async(_mp_compile_one, arr) pool.close() pool.join() # Return *all* object filenames, not just the ones we just built. return objects -CCompiler.compile = _mp_compile +# explicitly don't enable if environment says 1 processor +if MAX_PROCS != 1: + try: + # bug, only enable if we can make a Pool. see issue #790 and + # http://stackoverflow.com/questions/6033599/oserror-38-errno-38-with-multiprocessing + pool = Pool(2) + CCompiler.compile = _mp_compile + except Exception as msg: + print("Exception installing mp_compile, proceeding without: %s" %msg) +else: + print("Single threaded build, not installing mp_compile: %s processes" %MAX_PROCS) From cacc11eaedbb4a3008ef43384db41327135c5e6c Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 8 Jul 2014 12:24:06 -0700 Subject: [PATCH 4/5] Updated CHANGES.rst --- CHANGES.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index b80639db7..4bd8381d0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,15 @@ Changelog (Pillow) ================== +2.5.1 (2014-07-09) +------------------ + +- Fixed install issue if Multiprocessing.Pool is not available + [wiredfool] + +- 32bit mult overflow fix #782 + [wiredfool] + 2.5.0 (2014-07-01) ------------------ From ef041675a26ba3f99485083074de2b4bf43ca1b6 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Tue, 8 Jul 2014 12:44:51 -0700 Subject: [PATCH 5/5] Bump the versions --- PIL/__init__.py | 2 +- _imaging.c | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/__init__.py b/PIL/__init__.py index d446aa19b..50b13b158 100644 --- a/PIL/__init__.py +++ b/PIL/__init__.py @@ -12,7 +12,7 @@ # ;-) VERSION = '1.1.7' # PIL version -PILLOW_VERSION = '2.5.0' # Pillow +PILLOW_VERSION = '2.5.1' # Pillow _plugins = ['BmpImagePlugin', 'BufrStubImagePlugin', diff --git a/_imaging.c b/_imaging.c index 92258032f..7ac283e8a 100644 --- a/_imaging.c +++ b/_imaging.c @@ -71,7 +71,7 @@ * See the README file for information on usage and redistribution. */ -#define PILLOW_VERSION "2.5.0" +#define PILLOW_VERSION "2.5.1" #include "Python.h" diff --git a/setup.py b/setup.py index e94e34d28..40d50577f 100644 --- a/setup.py +++ b/setup.py @@ -90,7 +90,7 @@ except (ImportError, OSError): NAME = 'Pillow' -PILLOW_VERSION = '2.5.0' +PILLOW_VERSION = '2.5.1' TCL_ROOT = None JPEG_ROOT = None JPEG2K_ROOT = None