Skip to content

Commit

Permalink
Fix flags with multiple names for the same value.
Browse files Browse the repository at this point in the history
Flags constructs a dict __flags_values__ and uses it to cache
instances. However some flags in Glib such as G_IO_FLAG_MASK and
G_IO_FLAG_GET_MASK are aliases for the same int value, and will
override each other's place in the dictionary.

The dict length check is not necessary. It only reduces the number
of duplicate instances we keep, because if an instance is not
found in the dict, a new one is created anyway.
  • Loading branch information
Laszlo Pandy committed Feb 23, 2011
1 parent 3afbebe commit 824aeb7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gobject/pygflags.c
Expand Up @@ -161,7 +161,7 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
return NULL;
}

if (!PyDict_Check(values) || PyDict_Size(values) != eclass->n_values) {
if (!PyDict_Check(values)) {
PyErr_SetString(PyExc_TypeError, "__flags_values__ badly formed");
Py_DECREF(values);
g_type_class_unref(eclass);
Expand Down

0 comments on commit 824aeb7

Please sign in to comment.