From 6b93ae8cb09fec1c95b42f791858b93f0ca10a53 Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Sat, 26 Jul 2008 21:41:58 +0000 Subject: Issue warning if 'obj' is a PyGEnum of wrong type, i.e. not matching 2008-07-27 Paul Pogonyshev * gobject/pygtype.c (pyg_enum_get_value): Issue warning if 'obj' is a PyGEnum of wrong type, i.e. not matching 'enum_type' (bug #503771). svn path=/trunk/; revision=877 --- ChangeLog | 6 ++++++ gobject/pygtype.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index b22178a..a476e72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-27 Paul Pogonyshev + + * gobject/pygtype.c (pyg_enum_get_value): Issue warning if 'obj' + is a PyGEnum of wrong type, i.e. not matching 'enum_type' (bug + #503771). + 2008-07-26 Johan Dahlin reviewed by: diff --git a/gobject/pygtype.c b/gobject/pygtype.c index eb5b0bc..b4d029b 100644 --- a/gobject/pygtype.c +++ b/gobject/pygtype.c @@ -428,6 +428,12 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val) } else if (PyInt_Check(obj)) { *val = PyInt_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 (PyString_Check(obj)) { GEnumValue *info; char *str = PyString_AsString(obj); -- cgit