[Pyrex] Bug in CoerceFromPyTypeNode in 0.9.5

Peter Johnson peter at tortall.net
Mon Jan 29 00:51:19 UTC 2007


On Mon, 29 Jan 2007, Greg Ewing wrote:
> Peter Johnson wrote:
>> On Sun, 28 Jan 2007, Peter Johnson wrote:
>> 
>>> cdef extern from *:
>>>    ctypedef enum foo:
>>>        FOO
>>> cdef void func():
>>>    cdef foo x
>>>    map = [FOO]
>>>    x = map[0]
>> 
>> 
>> Sorry for all the self-replies, but an explicit cast does indeed fix this:
>>      x = <foo>map[0]
>> 
>> If the cast is indeed now required due to better type-strictness in 0.9.5, 
>> maybe all what's really needed here is just to give an informative error 
>> message rather than crashing.
>
> Yes, the typecast is needed now, because I've made it use
> the C++ rules for enum compatibility, which don't allow
> turning an int into an enum implicitly.
>
> But you should certainly get an error message instead
> of a crash.

Actually, with your patch to generate_result_code in your previous email 
(which works great), Pyrex successfully compiles the above example without 
the explicit cast and generates the correct cast in the generated C code.

Thanks,
Peter



More information about the Pyrex mailing list