Lisandro Dalcin, 24.02.2010 17:08:
> 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:

Looks reasonable at first glance. Could you add the above code as a test
case? I'll take a closer look then.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to