[Pyrex] int operations on enums fail with 0.9.5

Stefan Behnel stefan_ml at behnel.de
Mon Feb 12 06:01:41 UTC 2007


Hi,

in lxml, we use a couple of enums from libxml2, some of which have powers of
two as values. They are meant to be or-d to be passed as sets of options.
However, the | and & operations produce "invalid operand types" errors in
Pyrex 0.9.5(.1a). According to CHANGES.txt, there was a change regarding enums
in that version:

"Type rules for enums tightened for compatibility with C++"

May I ask why this was applied? I don't see how it is necessary to enforce
stricter rules here than the C compiler does. From the point of view of C,
enums are still the equivalent of named integer constants. Do I now have to
cast all enum values to <int>s before or-ing them? The same applies to
function return values of type enum, which are usually represented as "int" in
the libxml2 API. Using them strictly typed is not always that easy...

Hoping-it's-just-a-bug-ly,
Stefan





More information about the Pyrex mailing list