On 27 April 2010 19:02, fk <[email protected]> wrote:
> Hi,
>
> so, I stumbled about some funny behaviour with Python 3 support. Pretty
> sure those are bugs, however as I don‘t have a Trac account, I‘ll report
> them here; hope that‘s OK.
>
> i) As you may know, support for __cmp__ is gone in Python 3 - the
> relevant field in the type object structure has turned from ``cmpfunc
> tp_compare`` into ``void *reserved``. However, the Cython compiler even
> on Python 3 tries to put the comparison function into that slot:
>
>   0, /*tp_setattr*/
>   __pyx_pf_6bullet_9datatypes_7vector3___cmp__, /*tp_compare*/
>   __pyx_pf_6bullet_9datatypes_7vector3___repr__, /*tp_repr*/
>
> That works fine with C, however it doesn‘t with C++:
>
> bullet/datatypes.cpp:4835: error: invalid conversion from ‘int
> (*)(PyObject*, PyObject*)’ to ‘void*’
>

Below there is a quick fix:

diff -r 3adaf1ef25b9 Cython/Compiler/TypeSlots.py
--- a/Cython/Compiler/TypeSlots.py      Tue Apr 27 21:36:49 2010 +0200
+++ b/Cython/Compiler/TypeSlots.py      Tue Apr 27 20:14:34 2010 -0300
@@ -637,7 +637,7 @@
     EmptySlot("tp_print"), #MethodSlot(printfunc, "tp_print", "__print__"),
     EmptySlot("tp_getattr"),
     EmptySlot("tp_setattr"),
-    MethodSlot(cmpfunc, "tp_compare", "__cmp__"),
+    MethodSlot(cmpfunc, "tp_compare", "__cmp__", py3k = '<RESERVED>'),
     MethodSlot(reprfunc, "tp_repr", "__repr__"),

     SuiteSlot(PyNumberMethods, "PyNumberMethods", "tp_as_number"),

BTW, Should I push this?

We could try to synthesize __richcmp__ from __cmp__, but perhaps I'm
missing something.

In the mean time, I recommend you to move to use __richcmp__

> ii) The header files that get generated when you use ``public`` in the
> Cython code use the DL_IMPORT (and DL_EXPORT?) macro, which, again,
> seems to have disappeared with Python 3 (it has been deprecated since
> 2.3 already). The endorsed replacement, it appears, are the PyAPI_* macros.
>

The handling of public/api is something in my radar, but I'm not sure
what to do. Discussing here have not been helpful. BTW, the PyAPI_***
macros also have issues, as they depend on Py_ENABLE_SHARED. We should
find a solution that work as expected even in the case of a Python
build with static libraries (BTW, this is the default for official
Python tarballs).

-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to