On Thu, Apr 23, 2009 at 8:50 AM, Lisandro Dalcin <[email protected]> wrote:
> On Thu, Apr 23, 2009 at 2:37 AM, Stefan Behnel <[email protected]> wrote:
>> Hi Lisandro,
>>
>> I can't currently comment on the change itself, but I would prefer
>> duplicating the relevant part of the test case instead of replacing it, so
>> that we test both types of classes.
>>
>
> Well, there is other test case that covers new-style classes, but as
> it also has to do with __int__&__long__(), I'll duplicate the former.
>

Well, I've now duplicated the tests. All pass from 2.3 to 3.0,
including recent 2.7 trunk.

I'll wait for Robert's comments or more from Stefan's side.


>
>> Stefan
>>
>>
>> Lisandro Dalcin wrote:
>>> I do not have the time do dive deep enough to figure out the root of
>>> this difference, but here you have a patch that modifies a testcase to
>>> exercise the problem, and a quick fix for __Pyx_PyNumber_Int fixing
>>> the issue.
>>>
>>> If there are no objections, I'll push the fix to cython-devel... As
>>> this is related to rather old Python versions, I'm being a bit lazy as
>>> to re-openi #255, I would just push the fix :-)
>>>
>>>
>>> diff -r b550ee890c72 Cython/Compiler/PyrexTypes.py
>>> --- a/Cython/Compiler/PyrexTypes.py   Tue Apr 21 19:43:22 2009 -0700
>>> +++ b/Cython/Compiler/PyrexTypes.py   Wed Apr 22 19:52:13 2009 -0300
>>> @@ -1524,7 +1524,13 @@
>>>      return Py_INCREF(x), x;
>>>    m = Py_TYPE(x)->tp_as_number;
>>>  #if PY_VERSION_HEX < 0x03000000
>>> +#if PY_VERSION_HEX < 0x02050000
>>> +  if (m && m->nb_long &&
>>> +      (!PyInstance_Check(x) ||
>>> +       PyObject_HasAttrString(x, (char*)"__long__"))) {
>>> +#else
>>>    if (m && m->nb_long) {
>>> +#endif
>>>      name = "long";
>>>      res = PyNumber_Long(x);
>>>    }
>>> diff -r b550ee890c72 tests/run/c_int_types_T255.pyx
>>> --- a/tests/run/c_int_types_T255.pyx  Tue Apr 21 19:43:22 2009 -0700
>>> +++ b/tests/run/c_int_types_T255.pyx  Wed Apr 22 19:52:13 2009 -0300
>>> @@ -655,7 +655,7 @@
>>>  # -------------------------------------------------------------------
>>>  import sys
>>>
>>> -class MyInt(object):
>>> +class MyInt:
>>>     def __init__(self, value):
>>>        self.value = value
>>>     def __int__(self):
>>>
>>>
>> _______________________________________________
>> 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
>



-- 
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