[Pyrex] Bug in Pyrex 0.9?

Andreas Kostyrka andreas at mtg.co.at
Wed Oct 15 18:43:28 CEST 2003


Hello!

I'm trying to compile a cdef class that uses __contains__:

# t.pyx:
cdef class TEST:
    def __contains__(self, x):
        return int(x)

pyrexc t.pyx
/home/kostyrka/t.pyx:3:18: Return with value in void function

pyrex 0.8.2 compiles the above test case without any troubles.

The following patch fixes the above bug, I've fixed it by using the
signature of __cmp__ (that seems to make more sense).

Basically trying to 1:1 map the C function types to Signature objects
might not work as intended, as the C function types use "int" dually:
a) only as a exception signal.
b) as a data value.

And depending upon the use it must be mapped to 'r' or 'i'.

--- Pyrex/Compiler/TypeSlots.py.bak     Wed Oct 15 18:34:23 2003
+++ Pyrex/Compiler/TypeSlots.py Wed Oct 15 18:40:12 2003
@@ -461,7 +461,7 @@
        MethodSlot(intintargfunc, "sq_slice", "__getslice__"),
        EmptySlot("sq_ass_item"), # mp_ass_subscript used instead
        SyntheticSlot("sq_ass_slice", ["__setslice__", "__delslice__"], "0"),
-       MethodSlot(objargproc, "sq_contains", "__contains__"),
+       MethodSlot(cmpfunc, "sq_contains", "__contains__"),
        EmptySlot("sq_inplace_concat"), # nb_inplace_add used instead
        EmptySlot("sq_inplace_repeat"), # nb_inplace_multiply used instead
 )

 Andreas




More information about the Pyrex mailing list