summaryrefslogtreecommitdiffstats
path: root/gobject/pygenum.c
diff options
context:
space:
mode:
Diffstat (limited to 'gobject/pygenum.c')
-rw-r--r--gobject/pygenum.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gobject/pygenum.c b/gobject/pygenum.c
index c4c974b..80d241a 100644
--- a/gobject/pygenum.c
+++ b/gobject/pygenum.c
@@ -140,8 +140,12 @@ pyg_enum_from_gtype (GType gtype, int value)
values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict,
"__enum_values__");
retval = PyDict_GetItem(values, PyInt_FromLong(value));
+ if (!retval) {
+ PyErr_Clear();
+ return PyInt_FromLong(value);
+ }
+
Py_INCREF(retval);
-
return retval;
}