Attachments you submit will be routed for moderation. If you have an account, please log in first.

Ticket #3509: 0001-Avoid-using-numpy-1.6.1-in-invert_colors-function.patch

File 0001-Avoid-using-numpy-1.6.1-in-invert_colors-function.patch, 1.9 KB (added by humitos, 13 months ago)
  • Area.py

    From 9da82593bc033c692a2593a8d9ffe56949a38a4b Mon Sep 17 00:00:00 2001
    Message-Id: <9da82593bc033c692a2593a8d9ffe56949a38a4b.1335959378.git.humitos@gmail.com>
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Wed, 2 May 2012 08:49:21 -0300
    Subject: [PATCH Paint] Avoid using numpy 1.6.1 in invert_colors function
    
    There is a bug (or something like that) in numpy 1.6.1 that makes invert_color
    to not work properly. So, now we are checking for this version and if it's
    found we use the string implementation of this funcion instead.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     Area.py |   11 ++++++++++-
     1 file changed, 10 insertions(+), 1 deletion(-)
    
    diff --git a/Area.py b/Area.py
    index 50c0744..b889974 100644
    a b  
    10381038        def proc_invert_color(temp_pix): 
    10391039            try: 
    10401040                import numpy 
     1041                # HACK: This numpy version has a bug and breaks the 
     1042                # 'invert_color' function 
     1043                # http://bugs.sugarlabs.org/ticket/3509 
     1044                if numpy.__version__ == '1.6.1': 
     1045                    logging.warning('You have installed a version of numpy ' 
     1046                                    '(1.6.1) that has a bug and can\'t be ' 
     1047                                    'used. Using string module instead ' 
     1048                                    '(slower)') 
     1049                    raise ImportWarning 
    10411050                pix_manip2 = temp_pix.get_pixels_array() 
    10421051                pix_manip = numpy.ones(pix_manip2.shape, dtype=numpy.uint8) \ 
    10431052                            * 255 
    10441053                pix_manip2 = pix_manip - pix_manip2 
    10451054                temp_pix = gtk.gdk.pixbuf_new_from_array(pix_manip2, 
    10461055                        gtk.gdk.COLORSPACE_RGB, 8) 
    1047             except: 
     1056            except (ImportError, ImportWarning): 
    10481057                import string 
    10491058                a = temp_pix.get_pixels() 
    10501059                b = len(a) * ['\0']