summaryrefslogtreecommitdiffstats
path: root/gobject
diff options
context:
space:
mode:
Diffstat (limited to 'gobject')
-rw-r--r--gobject/pygtype.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index a9b18a4..601ea83 100644
--- a/gobject/pygtype.c
+++ b/gobject/pygtype.c
@@ -422,6 +422,16 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val)
g_type_name(enum_type),
g_type_name(((PyGEnum *) obj)->gtype));
}
+ /* Dumb code duplication, but probably not worth it to have yet another macro. */
+ } else if (PyLong_Check(obj)) {
+ *val = PyLong_AsLong(obj);
+ res = 0;
+
+ if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) {
+ g_warning("expected enumeration type %s, but got %s instead",
+ g_type_name(enum_type),
+ g_type_name(((PyGEnum *) obj)->gtype));
+ }
} else if (_PyUnicode_Check(obj)) {
GEnumValue *info;
char *str = _PyUnicode_AsString(obj);