diff options
author | Paul Pogonyshev <pogonyshev@gmx.net> | 2008-04-27 18:47:56 +0000 |
---|---|---|
committer | Paul Pogonyshev <paulp@src.gnome.org> | 2008-04-27 18:47:56 +0000 |
commit | 486a4d74244dcb7277710b8139f16be46a06492a (patch) | |
tree | ef0f7335f4a0112682ed0b9cd415a4ea41541e30 | |
parent | 8ea1bbdbd9b9e44e61e132b9cdc92517adff35a8 (diff) | |
download | pygobject-486a4d74244dcb7277710b8139f16be46a06492a.tar.gz pygobject-486a4d74244dcb7277710b8139f16be46a06492a.tar.xz pygobject-486a4d74244dcb7277710b8139f16be46a06492a.zip |
Fix: raise warning as exception if asked by PyErr_Warn().
2008-04-27 Paul Pogonyshev <pogonyshev@gmx.net>
* gobject/pygenum.c (pyg_enum_richcompare): Fix: raise warning as
exception if asked by PyErr_Warn().
* gobject/pygflags.c (pyg_flags_richcompare): Don't return NULL
after warning; more useful warning message.
(#480424, borrowing code by Mark Doffman)
svn path=/trunk/; revision=779
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | gobject/pygenum.c | 3 | ||||
-rw-r--r-- | gobject/pygflags.c | 8 |
3 files changed, 18 insertions, 3 deletions
@@ -1,3 +1,13 @@ +2008-04-27 Paul Pogonyshev <pogonyshev@gmx.net> + + * gobject/pygenum.c (pyg_enum_richcompare): Fix: raise warning as + exception if asked by PyErr_Warn(). + + * gobject/pygflags.c (pyg_flags_richcompare): Don't return NULL + after warning; more useful warning message. + + (#480424, borrowing code by Mark Doffman) + 2008-04-21 Johan Dahlin <johan@gnome.org> * codegen/h2def.py: Update link to defs format discussion diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 2d6c544..7de2b3b 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -40,7 +40,8 @@ pyg_enum_richcompare(PyGEnum *self, PyObject *other, int op) if (PyObject_TypeCheck(other, &PyGEnum_Type) && ((PyGEnum*)other)->gtype != self->gtype) { g_snprintf(warning, sizeof(warning), "comparing different enum types: %s and %s", g_type_name(self->gtype), g_type_name(((PyGEnum*)other)->gtype)); - PyErr_Warn(PyExc_Warning, warning); + if (PyErr_Warn(PyExc_Warning, warning)) + return NULL; } return pyg_integer_richcompare((PyObject *)self, other, op); diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 853f5c2..4f028b9 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -32,14 +32,18 @@ static PyObject * pyg_flags_richcompare(PyGFlags *self, PyObject *other, int op) { + static char warning[256]; + if (!PyInt_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } if (PyObject_TypeCheck(other, &PyGFlags_Type) && ((PyGFlags*)other)->gtype != self->gtype) { - PyErr_Warn(PyExc_Warning, "comparing different flags types"); - return NULL; + g_snprintf(warning, sizeof(warning), "comparing different flags types: %s and %s", + g_type_name(self->gtype), g_type_name(((PyGFlags*)other)->gtype)); + if (PyErr_Warn(PyExc_Warning, warning)) + return NULL; } return pyg_integer_richcompare((PyObject *)self, other, op); |