Hard freeze exception for two regressions from pygobject 3.1.92

Hello release team,

(CCing the other active maintainers of pygobject).

We released pygobject 3.1.92 on Monday, and it turned out to have two

 * Marshalling of GHashTables that contain GValues inadvertedly got
   broken by the fix that makes pygobject work on big-endian machines:


   This is fixed with

   which is a straightforward patch (also attached for your
   convenience). If you prefer, I can also reduce the cherry-pick to
   just adding the missing "case GI_TYPE_TAG_INTERFACE:", and drop the
   g_assert change for the stable branch.

   We also have a new test case for this which will ensure that it
   won't break again. These are attached to above bug report, but due
   to the current hard freeze we can't push them into
   gobject-introspection git yet, so they will need to land after the

   I strongly recommend to allow this, as it is a significant regression.

 * When using the Gtk.TreeStore.append() API (same for ListStore, and
   the prepend() and related methods), and you supply None values for
   columns, you now get warnings. They don't actually break your
   program, but nevertheless look ugly:


   This was introduced with


   which changed the behaviour from setting non-None columns to
   setting them all. The fix already landed in master:


   and I would like to apply it to the pygobject-3-2 branch (which is
   what GNOME 3.4 will release with) as well. For convenience I attach
   the patch as well.

   This code is well-covered with tests:


   onwards, so I am very confident that this does not break anything.

   If you are hesitant about this one, I'm also ok with not
   cherry-picking this, as it's mostly a cosmetical issue (but might
   flood .xsession-errors and debug logs with bogus warnings).

Thank you in advance!


Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
From 8d85d6639778ec6364235071d272d67e7aae49ae Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin pitt ubuntu com>
Date: Wed, 21 Mar 2012 14:34:36 +0100
Subject: [PATCH] Fix warnings on None values in added tree/list store rows

Commit bf8c95836e1c changed the List/TreeStore overrides to use
insert_with_valuesv(), but supplied all columns instead of just those which are
not None. With this, None values cause warnings like

(runtests.py:12375): Gtk-WARNING **: /build/buildd/gtk+3.0-3.3.20/./gtk/gtkliststore.c:851: Unable to convert from (null) to gboolean

Update the tests to make warnings fatal, to catch this better.

Change _convert_row() to skip the None entries and return the list of not-None
columns, and use the latter instead of a simple range(n_columns). This matches
the behaviour before bf8c95836e1c, where columns with None values were skipped
as well.

 gi/overrides/Gtk.py     |   26 ++++++++++++++------------
 tests/test_overrides.py |    5 +++++
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 9d3ba0a..4018b32 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -809,19 +809,23 @@ class TreeModel(Gtk.TreeModel):
             raise ValueError('row sequence has the incorrect number of elements')
         result = []
-        for i in range(n_columns):
-            value = row[i]
-            result.append(self._convert_value(i, value))
-        return result
+        columns = []
+        for cur_col, value in enumerate(row):
+            # do not try to set None values, they are causing warnings
+            if value is None:
+                continue
+            result.append(self._convert_value(cur_col, value))
+            columns.append(cur_col)
+        return (result, columns)
     def set_row(self, treeiter, row):
-        converted_row = self._convert_row(row)
-        for i in range(self.get_n_columns()):
-            value = row[i]
+        converted_row, columns = self._convert_row(row)
+        for column in columns:
+            value = row[column]
             if value is None:
                continue  # None means skip this row
-            self.set_value(treeiter, i, value)
+            self.set_value(treeiter, column, value)
     def _convert_value(self, column, value):
             if value is None:
@@ -949,8 +953,7 @@ class ListStore(Gtk.ListStore, TreeModel, TreeSortable):
     def _do_insert(self, position, row):
         if row is not None:
-            row = self._convert_row(row)
-            columns = range(len(row))
+            row, columns = self._convert_row(row)
             treeiter = self.insert_with_valuesv(position, columns, row)
             treeiter = Gtk.ListStore.insert(self, position)
@@ -1179,8 +1182,7 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable):
     def _do_insert(self, parent, position, row):
         if row is not None:
-            row = self._convert_row(row)
-            columns = range(len(row))
+            row, columns = self._convert_row(row)
             treeiter = self.insert_with_values(parent, position, columns, row)
             treeiter = Gtk.TreeStore.insert(self, parent, position)
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 58c77bf..5a3457c 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -19,6 +19,11 @@ from gi.repository import GdkPixbuf
 import gi.overrides as overrides
 import gi.types
+# in general we don't want tests to raise warnings, except when explicitly
+# testing with bad values; in those cases it will temporarily be set back to
 class TestGLib(unittest.TestCase):
     def test_gvariant_create(self):

From efcb4b0b32c4dda06c3eeec83802fc0f302f0d27 Mon Sep 17 00:00:00 2001
From: Alberto Mardegan <alberto mardegan canonical com>
Date: Tue, 20 Mar 2012 14:55:07 +0400
Subject: [PATCH] Support marshalling GI_TYPE_TAG_INTERFACE

Marshalling of interfaces got broken with commit

Also, do not abort on unsupported types, but log a critical failure and

 gi/pygi-marshal-from-py.c |    3 ++-
 gi/pygi-marshal-to-py.c   |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gi/pygi-marshal-from-py.c b/gi/pygi-marshal-from-py.c
index 962747f..c789d1d 100644
--- a/gi/pygi-marshal-from-py.c
+++ b/gi/pygi-marshal-from-py.c
@@ -1066,9 +1066,10 @@ _pygi_arg_to_hash_pointer (const GIArgument *arg,
             return GINT_TO_POINTER(arg->v_int32);
         case GI_TYPE_TAG_UTF8:
         case GI_TYPE_TAG_FILENAME:
+        case GI_TYPE_TAG_INTERFACE:
             return arg->v_pointer;
-            g_assert_not_reached();
+            g_critical("Unsupported type %s", g_type_tag_to_string(type_tag));
             return arg->v_pointer;
diff --git a/gi/pygi-marshal-to-py.c b/gi/pygi-marshal-to-py.c
index ce93257..3af443d 100644
--- a/gi/pygi-marshal-to-py.c
+++ b/gi/pygi-marshal-to-py.c
@@ -521,9 +521,10 @@ _pygi_hash_pointer_to_arg (GIArgument *arg,
         case GI_TYPE_TAG_UTF8:
         case GI_TYPE_TAG_FILENAME:
+        case GI_TYPE_TAG_INTERFACE:
-            g_assert_not_reached();
+            g_critical("Unsupported type %s", g_type_tag_to_string(type_tag));

Attachment: signature.asc
Description: Digital signature

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