From f1333617d5d5bd34fb5a3338a3e5d851e1ef6e2a Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 5 Mar 2015 23:14:36 +0200 Subject: [PATCH 1/2] Replace harcoded assumption of RAND_MAX with constant. It caused an infinite loop if RAND_MAX > 32767 --- libImaging/Effects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libImaging/Effects.c b/libImaging/Effects.c index eb598d968..a3f5e7cd9 100644 --- a/libImaging/Effects.c +++ b/libImaging/Effects.c @@ -98,8 +98,8 @@ ImagingEffectNoise(int xsize, int ysize, float sigma) /* after numerical recipes */ double v1, v2, radius, factor; do { - v1 = rand()*(2.0/32767.0) - 1.0; - v2 = rand()*(2.0/32767.0) - 1.0; + v1 = rand()*(2.0/RAND_MAX) - 1.0; + v2 = rand()*(2.0/RAND_MAX) - 1.0; radius= v1*v1 + v2*v2; } while (radius >= 1.0); factor = sqrt(-2.0*log(radius)/radius); From 9bd38bfa06fd14fce3c998877f9dfe35e0cf7fb5 Mon Sep 17 00:00:00 2001 From: hugovk Date: Thu, 5 Mar 2015 23:21:42 +0200 Subject: [PATCH 2/2] Run test_effect_noise() on non-Windows, don't be too strict --- Tests/test_image.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Tests/test_image.py b/Tests/test_image.py index 26e45b10a..de43b010e 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -168,8 +168,6 @@ class TestImage(PillowTestCase): ValueError, lambda: Image.effect_mandelbrot(size, extent, quality)) - @unittest.skipUnless(sys.platform.startswith('win32'), - "Stalls on Travis CI, passes on Windows") def test_effect_noise(self): # Arrange size = (100, 100) @@ -180,8 +178,8 @@ class TestImage(PillowTestCase): # Assert self.assertEqual(im.size, (100, 100)) - self.assertEqual(im.getpixel((0, 0)), 60) - self.assertEqual(im.getpixel((0, 1)), 28) + self.assertEqual(im.mode, "L") + self.assertNotEqual(im.getpixel((0, 0)), im.getpixel((0, 1))) def test_effect_spread(self): # Arrange