Hello,

while converting a class from pure Python to Cython, I've come across
the following:

  $ cat r.pyx
  cdef class r(object):
       cdef long long n
       cdef long long d

       def __init__(self, long long n, long long d):
           self.n = n
           self.d = d

       def __int__(self):
           return (self.n // self.d)

       __long__ = __int__

  $ cython -v r.pyx
  Compiling /tmp/r.pyx

  $ gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c r.c -o r.o
  r.c:487: error: ‘None’ undeclared here (not in a function)

  $ sed -e '484,490!d;488i^^^^^^^^^^^^^^^^^^^^^^^^ up here' r.c
    0, /*nb_coerce*/
    #endif
    __pyx_pf_1r_1r___int__, /*nb_int*/
    None, /*nb_long*/
  ^^^^^^^^^^^^^^^^^^^^^^^^ up here
    0, /*nb_float*/
    #if PY_MAJOR_VERSION < 3
    0, /*nb_oct*/

I understand that "__long__ = __int__" is not the correct way to do
method aliasing in Cython, but the compiler should probably emit a
warning -- generating incorrect C code looks like a bug.

Best regards,
Riccardo

-- 
Riccardo Murri, via Rossée 17, 6987 Caslano (CH)
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to