After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689277 - TreeModelRow does not consider do_get_value implementation for a custom model.
TreeModelRow does not consider do_get_value implementation for a custom model.
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on: 727004
Blocks:
 
 
Reported: 2012-11-29 13:44 UTC by Manuel Quiñones
Modified: 2018-01-10 20:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
TestCase (2.58 KB, application/octet-stream)
2012-11-30 12:57 UTC, Manuel Quiñones
Details

Description Manuel Quiñones 2012-11-29 13:44:45 UTC
Having a custom model that inherits Gtk.TreeModel and implements
do_get_value, calling row[model_index] I get this traceback:

Traceback (most recent call last):
  • File "/home/erikos/sugar-build/install/lib/python2.7/site-packages/jarabe/journal/listview.py", line 668 in create_palette
    if row[self._model_column_index] is not None:
  • File "/home/erikos/sugar-build/install/lib/python2.7/site-packages/gi/overrides/Gtk.py", line 1136 in __getitem__
    return self.model.get_value(self.iter, key)
  • File "/home/erikos/sugar-build/install/lib/python2.7/site-packages/gi/types.py", line 47 in function
    return info.invoke(*args, **kwargs)
TypeError: unknown type (null)

I see pygobject has an override [1] which is calling get_value in the
model.  So replacing my code like this is the same:

-        if row[self._model_column_index] is not None:
-            nick, xo_color = row[self._model_column_index]
+        if row.model.get_value(row.iter, self._model_column_index) is not None:
+            nick, xo_color = row.model.get_value(row.iter, self._model_column_index)

Now if I rename get_value by do_get_value, I get the expected result.

-        if row[self._model_column_index] is not None:
-            nick, xo_color = row[self._model_column_index]
+        if row.model.do_get_value(row.iter, self._model_column_index) is not None:
+            nick, xo_color = row.model.do_get_value(row.iter, self._model_column_index)

[1] http://git.gnome.org/browse/pygobject/tree/gi/overrides/Gtk.py#n1132
Comment 1 Manuel Quiñones 2012-11-29 13:52:47 UTC
This was seen in the Sugar learning platform, the ticket is http://bugs.sugarlabs.org/ticket/3888 .
Comment 2 Manuel Quiñones 2012-11-30 12:57:05 UTC
Created attachment 230270 [details]
TestCase
Comment 3 Manuel Quiñones 2012-11-30 13:04:02 UTC
The issue is when do_get_value returns a tuple like in our code here [1].  The attached testcase shows that only the first element of the tuple is returned.

[1] http://git.sugarlabs.org/sugar/mainline/blobs/master/src/jarabe/journal/listmodel.py#line197
Comment 4 Simon Feltman 2013-07-19 02:11:31 UTC
Confirmed. A work around is to return the tuple as a GValue:

return GObject.Value(GObject.TYPE_PYOBJECT, (len(director), director))

This is most likely confusion in how return/out arg marshaling works.
Comment 5 Simon Feltman 2013-09-11 11:36:05 UTC
A cleaner workaround is to return a list:

return [len(director), director]

The problem is return/out arg marshaling assumes a tuple type means multiple return values:
https://git.gnome.org/browse/pygobject/tree/gi/pygi-closure.c?id=3.9.91#n459

We need get the count of expected return/out values and if it is greater than one use a sequence check and pull the items out (also give an error if we expect more than one out values and we don't have a sequence).
Comment 6 Simon Feltman 2014-08-06 04:25:55 UTC
Marking as depending on bug 727004 since the patches their will either fix this or move code around where this should be fixed.
Comment 7 GNOME Infrastructure Team 2018-01-10 20:20:56 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/39.