Invert colors function doesn't work well with numpy version 1.6.1, so this
PATCH is to avoid using this version and use the string module version (slower)
of invert colors instead.

Signed-off-by: Manuel Kaufmann <[email protected]>
---
 Area.py |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/Area.py b/Area.py
index 24f02d4..510cb79 100644
--- a/Area.py
+++ b/Area.py
@@ -1033,13 +1033,22 @@ class Area(gtk.DrawingArea):
         def proc_invert_color(temp_pix):
             try:
                 import numpy
+                # HACK: This numpy version has a bug and breaks the
+                # 'invert_color' function
+                # http://bugs.sugarlabs.org/ticket/3509
+                if numpy.__version__ == '1.6.1':
+                    logging.warning('You have installed a version of numpy '
+                                    '(1.6.1) that has a bug and can\'t be '
+                                    'used. Using string module instead '
+                                    '(slower)')
+                    raise ImportWarning
                 pix_manip2 = temp_pix.get_pixels_array()
                 pix_manip = numpy.ones(pix_manip2.shape, dtype=numpy.uint8) \
                             * 255
                 pix_manip2 = pix_manip - pix_manip2
                 temp_pix = gtk.gdk.pixbuf_new_from_array(pix_manip2,
                         gtk.gdk.COLORSPACE_RGB, 8)
-            except:
+            except (ImportError, ImportWarning):
                 import string
                 a = temp_pix.get_pixels()
                 b = len(a) * ['\0']
-- 
1.7.10

_______________________________________________
Sugar-devel mailing list
[email protected]
http://lists.sugarlabs.org/listinfo/sugar-devel

Reply via email to