I believe that pyg_value_as_pyobj should return a valid PyObject* if a
GValue is holding a PY_TYPE_OBJECT.  This means we should translate
NULL returns to Py_None.

Comments before committing?

Cheers,

Matt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/ChangeLog,v
retrieving revision 1.412
diff -u -r1.412 ChangeLog
--- ChangeLog   11 Jun 2002 19:14:38 -0000      1.412
+++ ChangeLog   14 Jun 2002 20:39:15 -0000
@@ -1,3 +1,9 @@
+2002-06-14  Matt Wilson  <[EMAIL PROTECTED]>
+
+       * pygtype.c (pyg_value_as_pyobject): if a value holds a PyObject*,
+       the code that is getting the value is expecting a valid object.
+       Translate NULL pointers to Py_None.
+
 Fri Jun  7 12:39:27 2002  Jonathan Blandford  <[EMAIL PROTECTED]>
 
        * gtk/gtk.override (pygtk_tree_selection_foreach_marshal): fix
Index: pygtype.c
===================================================================
RCS file: /cvs/gnome/gnome-python/pygtk/pygtype.c,v
retrieving revision 1.10
diff -u -r1.10 pygtype.c
--- pygtype.c   31 May 2002 19:59:47 -0000      1.10
+++ pygtype.c   14 Jun 2002 20:39:15 -0000
@@ -565,9 +565,15 @@
        {
            PyGBoxedMarshal *bm;
 
-           if (G_VALUE_HOLDS(value, PY_TYPE_OBJECT))
-               return (PyObject *)g_value_dup_boxed(value);
-
+           if (G_VALUE_HOLDS(value, PY_TYPE_OBJECT)) {
+               PyObject *ret = (PyObject *)g_value_dup_boxed(value);
+               if (ret == NULL) {
+                   Py_INCREF(Py_None);
+                   return Py_None;
+               }
+               return ret;
+           }
+           
            bm = pyg_boxed_lookup(G_VALUE_TYPE(value));
            if (bm)
                return bm->fromvalue(value);

Reply via email to