diff options
| author | Paul Pogonyshev <pogonyshev@gmx.net> | 2008-07-26 21:41:58 +0000 |
|---|---|---|
| committer | Paul Pogonyshev <paulp@src.gnome.org> | 2008-07-26 21:41:58 +0000 |
| commit | 6b93ae8cb09fec1c95b42f791858b93f0ca10a53 (patch) | |
| tree | 4deeb0c81074015249771eef1d3273a3224a4a53 | |
| parent | da75d8feaaf9141696f42956c14d6518a8350a51 (diff) | |
| download | pygobject-6b93ae8cb09fec1c95b42f791858b93f0ca10a53.tar.gz pygobject-6b93ae8cb09fec1c95b42f791858b93f0ca10a53.tar.xz pygobject-6b93ae8cb09fec1c95b42f791858b93f0ca10a53.zip | |
Issue warning if 'obj' is a PyGEnum of wrong type, i.e. not matching
2008-07-27 Paul Pogonyshev <pogonyshev@gmx.net>
* 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
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | gobject/pygtype.c | 6 |
2 files changed, 12 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2008-07-27 Paul Pogonyshev <pogonyshev@gmx.net> + + * 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 <johan@gnome.org> reviewed by: <delete if not using a buddy> 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); |
