Incorrect values for flags constructed from typelib data.
Presume that following C code is processed by g-ir-scanner, put into typelib and used from pygobject:
typedef enum {
FLAGS_A_X = (1 << 0),
FLAGS_A_Y = (1 << 1),
FLAGS_A_ANY = ~0,
} FlagsA;
Then I would expect int(Flags.A.ANY) to be 4294967295, but one instead gets:
>>> from gi.repository import Flags
>>> Flags.A.ANY
<flags FLAGS_A_X | FLAGS_A_Y | FLAGS_A_ANY of type Flags.A>
>>> int(Flags.A.ANY)
18446744073709551615
Flag values that are used with g_flags_register_static are correct, those attached to a type in __flags_values__ are correct as well, but those that are exposed as Python attributes are incorrect.
This happens because they are constructed as wrapper(value_info.get_value()))
,
where get_value() will return value as it is in C, which is -1, which will
then get turned into ULONG_MAX in pyg_flags_new:
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "k", kwlist, &value))
return NULL;
While I am reporting this issue in pygobject, one might consider this to be a problem somewhere on the way before this values even reaches the pygobect from typelib. For example, one can say that negative flags are wrong in the first place, and it should be fixed earlier. Once could even claim that those enumerator values should be unsigned in C, though you need to go out of the way to do that (neither GLib nor GStreamer actually do that).