GNOME Bugzilla – Bug 375589
gobject.handler_block_by_func() does not accept bound methods
Last modified: 2007-04-06 20:44:57 UTC
Please describe the problem: while gtk.<SomeWidget>.connect() accepts bound methods, gtk.<SomeWidget>.handler_block_by_func() does not with a strangish error: SystemError: Objects/funcobject.c:128: bad argument to internal function and somewhat incorrect python backtrace Steps to reproduce: #!/usr/bin/python import gtk class A: def __init__(self): self.win = gtk.Window() self.con = gtk.VBox() self.win.add(self.con) for i in range(2): but = gtk.ToggleButton("Stubborn button %d" % i) but.connect("toggled", self.callback) self.con.add(but) self.win.show_all() def callback(self, w): for ww in w.get_parent().get_children(): ww.handler_block_by_func(self.callback) ww.set_active(0) ww.handler_unblock_by_func(self.callback) a = A() gtk.main() Actual results: Traceback (most recent call last):
+ Trace 86707
for ww in w.get_parent().get_children():
# button indeed untoggles itself and neighbours # an error is printed # python backtrace is incorrect (offending line is actually one below) Expected results: button untoggles itself and neighbours (hence stubborn) no errors occur if errors do occur backtrace should point to the offending line - ww.handler_block_by_func(self.callback) Does this happen every time? yes Other information:
Thanks for the report. Do you think you could write a small test case that demonstrates this behavior of handler_block_by_func?
Thanks for the bug report, fixed in CVS: Checking in ChangeLog; /cvs/gnome/pygobject/ChangeLog,v <-- ChangeLog new revision: 1.112; previous revision: 1.111 done Checking in gobject/pygtype.c; /cvs/gnome/pygobject/gobject/pygtype.c,v <-- pygtype.c new revision: 1.54; previous revision: 1.53 done Checking in tests/test_signal.py; /cvs/gnome/pygobject/tests/test_signal.py,v <-- test_signal.py new revision: 1.15; previous revision: 1.14 done
*** Bug 406485 has been marked as a duplicate of this bug. ***