Suppose this code:

cdef extern from *:
    ctypedef class __builtin__.list [ object PyListObject ]:
        pass

def slice_of_typed_value():

    """
    >>> slice_of_typed_value()
    [1, 2, 3]
    """
    cdef object a = []
    cdef list L = [1, 2, 3]
    a[:] = L
    return a


GCC complains (complains in C, but of course an error in C++) like this:

slice2.c: In function ‘__pyx_pf_6slice2_slice_of_typed_value’:
slice2.c:1107: warning: passing argument 4 of ‘PySequence_SetSlice’
from incompatible pointer type
/usr/include/python2.6/abstract.h:1118: note: expected ‘struct
PyObject *’ but argument is of type ‘struct PyListObject *’


Is the patch below the correct way to fix it?:

diff -r e16a6487e8c2 Cython/Compiler/ExprNodes.py
--- a/Cython/Compiler/ExprNodes.py      Wed Feb 24 14:23:58 2010 +0100
+++ b/Cython/Compiler/ExprNodes.py      Wed Feb 24 13:06:31 2010 -0300
@@ -2279,7 +2279,7 @@
                     self.base.py_result(),
                     self.start_code(),
                     self.stop_code(),
-                    rhs.result()))
+                    rhs.py_result()))
         else:
             start_offset = ''
             if self.start:



-- 
Lisandro Dalcin
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to