summaryrefslogtreecommitdiffstats
path: root/tests/test_signal.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2006-11-18 12:58:43 +0000
committerJohan Dahlin <johan@src.gnome.org>2006-11-18 12:58:43 +0000
commitf27cb5674c9526d1f1fc4537bd4612c42d9dce4d (patch)
tree189cf64e50a7b11160cf831f122a33ed4c252470 /tests/test_signal.py
parent2de07b5d97911346eb95ded4f86d1d274cca8a0a (diff)
downloadpygobject-f27cb5674c9526d1f1fc4537bd4612c42d9dce4d.tar.gz
pygobject-f27cb5674c9526d1f1fc4537bd4612c42d9dce4d.tar.xz
pygobject-f27cb5674c9526d1f1fc4537bd4612c42d9dce4d.zip
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)
Diffstat (limited to 'tests/test_signal.py')
-rw-r--r--tests/test_signal.py27
1 files changed, 17 insertions, 10 deletions
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,)) }