I've uploaded a patch to the tracker fixing #287.

Deciding on what to do here was a real pain. I really think that this
is the best thing to do, for many reasons I'm now so tired to write
down. If any of you think any part of this is wrong, comments very
welcome, but I would appreciate you provide also a valid use case or
Python/Cython code that prove me wrong; I was not able to find any
single one.


On Sun, Apr 19, 2009 at 5:02 AM, Riccardo Murri
<[email protected]> wrote:
> 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
>



-- 
Lisandro Dalcín
---------------
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