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


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