On Fri, Apr 17, 2009 at 3:09 PM, Stefan Behnel <[email protected]> wrote: > Riccardo Murri wrote: >> 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*/ > > Yes, that's a bug. I assume that the above code does not make Cython set > up the C level function name. > > Raising an error here would work for now. > > >> I understand that "__long__ = __int__" is not the correct way to do >> method aliasing in Cython > > ... and that's a feature request, it would be nice to make that work. > Could you create two tickets for those? >
Done: tickets #287 and #288 http://trac.cython.org/cython_trac/ticket/287 http://trac.cython.org/cython_trac/ticket/288 Thank you! Riccardo -- Riccardo Murri, via Rossée 17, 6987 Caslano (CH) _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
