Dear Cython list,
while investigating the type semantics and constraints of Cython I
stumbled over a problem I consider a bug. Here is some brief description
using an example
# point.pyx
#
# defines an extension type and a conversion between a C struct and an
extension type
#
import random
cdef struct CPoint:
int x
int y
cdef class ExtPoint:
cdef int x
cdef int y
cdef convert(self, CPoint pt):
self.x = pt.x
self.y = pt.y
cdef convert(self, CPoint pt):
self.x = pt.x
self.y = pt.y
cpdef test():
cdef CPoint pt
pt.x = random.randrange(100)
pt.y = random.randrange(100)
ep = ExtPoint()
convert(ep, pt) # o.k - compiles
ep.convert(pt) # n.o.k - fails to compile
return ep
# end of point.pyx
The standalone convert() function equals the convert() C-method of the
ExtPoint extension type. However the compiler accepts the function call
but rejects the method call:
Error converting Pyrex file to C:
------------------------------------------------------------
...
cdef CPoint pt
pt.x = random.randrange(100)
pt.y = random.randrange(100)
ep = ExtPoint()
convert(ep, pt) # o.k - compiles
ep.convert(pt) # n.o.k - fails to compile
^
------------------------------------------------------------
point.pyx:91:17: Cannot convert 'CPoint' to Python object
There is no indication why the compiler tries to perform an automatic
type conversion since the C method isn't exposed to Python anyway.
Regards, Kay
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev