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 711173 - TreeViewColumn set_cell_data_func doesn't accept None as callback anymore
TreeViewColumn set_cell_data_func doesn't accept None as callback anymore
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2013-10-30 19:33 UTC by Giuseppe Scrivano
Modified: 2013-11-04 11:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Remove overzealous argument checking for callback userdata (2.24 KB, patch)
2013-11-04 11:42 UTC, Simon Feltman
committed Details | Review

Description Giuseppe Scrivano 2013-10-30 19:33:32 UTC
the git master version of pygobject raises an exception when Gtk.TreeViewColumn.set_cell_data_func(Gtk.CellRendererText(), None, None) is used.

We are using code to workaround a memory leak problem that is present in old versions (it was just recently fixed in pygobject) and we would like to keep supporting older pygobject versions as well.

As a reproducer, these four lines show the problem:

#############################################
from gi.repository import Gtk
col = Gtk.TreeViewColumn("Name")
txt = Gtk.CellRendererText()
col.set_cell_data_func(txt, None, None)
#############################################

and this is the error I get:

Traceback (most recent call last):
  • File "repro.py", line 5 in <module>
    col.set_cell_data_func(txt, None, None)
  • File "/usr/lib/python2.7/site-packages/gi/overrides/Gtk.py", line 1320 in set_cell_data_func
    super(TreeViewColumn, self).set_cell_data_func(cell_renderer, func, func_data)
TypeError: When passing None for a callback userdata must also be None


It seems that userdata is not correctly checked, as in the code it is None.
Comment 1 Cole Robinson 2013-10-31 14:34:31 UTC
To expand a bit, the above code works fine on 3.10, but fails on 3.11. So this is a regression.

As Guiseppe says, we use this code to unregister unused cell_data callbacks in virt-manager to help avoid the memory leak in bug 709397 which isn't fixed in all distros yet.
Comment 2 Simon Feltman 2013-11-04 11:42:52 UTC
The following fix has been pushed:
79aea26 Remove overzealous argument checking for callback userdata

The argument check here has always stood out as a bit odd to me. So I've 
removed it to fix this bug and simplify things.
Comment 3 Simon Feltman 2013-11-04 11:42:55 UTC
Created attachment 258914 [details] [review]
Remove overzealous argument checking for callback userdata

Remove check which ensures userdata is None if the callback is None.
This check would need to become more complicated with recent versions of
PyGObject where userdata can be variable (would also need to check against
a tuple containing None). Instead of adding more complex checking, simply
remove the checking as it is unnecessary to begin with.