[pygobject] 2009-04-17 Paul Pogonyshev <pogonyshev gmx net>



commit 4c18e963aa85577646651c531e3d5bfda0308934
Author: Paul Pogonyshev <pogonyshev gmx net>
Date:   Fri Apr 17 23:57:27 2009 +0300

    2009-04-17  Paul Pogonyshev  <pogonyshev gmx net>
    
    	Bug 568499 â?? CellRendererPixbuf stock-size property has wrong type
    
    	* gobject/pygtype.c (pyg_enum_get_value): Also accept long
    	integers.
---
 ChangeLog         |    7 +++++++
 gobject/pygtype.c |   10 ++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d3be769..cda0fa7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-17  Paul Pogonyshev  <pogonyshev gmx net>
+
+	Bug 568499 â?? CellRendererPixbuf stock-size property has wrong type
+
+	* gobject/pygtype.c (pyg_enum_get_value): Also accept long
+	integers.
+
 2009-04-15  Götz Waschk  <waschk mandriva org>
 
 	Bug 550231 â?? missing dep on libffi in pygobject-2.0.pc
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);



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