pygobject r779 - in trunk: . gobject



Author: paulp
Date: Sun Apr 27 18:47:56 2008
New Revision: 779
URL: http://svn.gnome.org/viewvc/pygobject?rev=779&view=rev

Log:
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)


Modified:
   trunk/ChangeLog
   trunk/gobject/pygenum.c
   trunk/gobject/pygflags.c

Modified: trunk/gobject/pygenum.c
==============================================================================
--- trunk/gobject/pygenum.c	(original)
+++ trunk/gobject/pygenum.c	Sun Apr 27 18:47:56 2008
@@ -40,7 +40,8 @@
     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);

Modified: trunk/gobject/pygflags.c
==============================================================================
--- trunk/gobject/pygflags.c	(original)
+++ trunk/gobject/pygflags.c	Sun Apr 27 18:47:56 2008
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]