From f27cb5674c9526d1f1fc4537bd4612c42d9dce4d Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sat, 18 Nov 2006 12:58:43 +0000 Subject: Use PyObject_Cmp instead of comparing function closure addresses, which * gobject/pygtype.c (gclosure_from_pyfunc): Use PyObject_Cmp instead of comparing function closure addresses, which makes it possible to use any callable and not just functions. Fixes #375589 (Dima) --- tests/test_signal.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/test_signal.py b/tests/test_signal.py index 6312711..d22281e 100644 --- a/tests/test_signal.py +++ b/tests/test_signal.py @@ -242,6 +242,23 @@ class TestClosures(unittest.TestCase): e.emit('signal') self.assertEqual(self.count, 1) + def testHandlerBlockMethod(self): + # Filed as #375589 + class A: + def __init__(self): + self.a = 0 + + def callback(self, o): + self.a = 1 + o.handler_block_by_func(self.callback) + + inst = A() + e = E() + e.connect("signal", inst.callback) + e.emit('signal') + self.assertEqual(inst.a, 1) + gc.collect() + def testGString(self): class C(gobject.GObject): __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_GSTRING, @@ -257,16 +274,6 @@ class TestClosures(unittest.TestCase): data = c.emit("my_signal", "\01\00\02") self.assertEqual(data, "\02\00\01") - def _test_bug375589(self): - class A: - def callback(self, o): - o.handler_block_by_func(self.callback) - - e = E() - e.connect("signal", A().callback) - e.emit('signal') - gc.collect() - class SigPropClass(gobject.GObject): __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_INT,)) } -- cgit