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 375589 - gobject.handler_block_by_func() does not accept bound methods
gobject.handler_block_by_func() does not accept bound methods
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
2.10.x
Other All
: Normal minor
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 406485 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-11-15 16:45 UTC by Dima Tisnek
Modified: 2007-04-06 20:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dima Tisnek 2006-11-15 16:45:52 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):
  • File "./test-pygtk.py", line 15 in callback
    for ww in w.get_parent().get_children():
SystemError: Objects/funcobject.c:128: bad argument to internal function

# 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:
Comment 1 Johan (not receiving bugmail) Dahlin 2006-11-16 12:13:25 UTC
Thanks for the report. Do you think you could write a small test case that demonstrates this behavior of handler_block_by_func?
Comment 2 Johan (not receiving bugmail) Dahlin 2006-11-18 12:59:06 UTC
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
Comment 3 Johan (not receiving bugmail) Dahlin 2007-04-06 20:44:57 UTC
*** Bug 406485 has been marked as a duplicate of this bug. ***