summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--gobject/pygsource.c4
-rw-r--r--tests/test_source.py28
3 files changed, 35 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b65231..6e28bc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-08 Johan Dahlin <jdahlin@async.com.br>
+
+ * gobject/pygsource.c:
+ * tests/test_source.py:
+ Unbreak Source.prepare (#523075, Bryan Silverthorn)
+
2008-04-08 Johan Dahlin <johan@gnome.org>
* gio/gfile.override (_wrap__install_file_meta): Fix a couple of
diff --git a/gobject/pygsource.c b/gobject/pygsource.c
index 900bd4f..9e831e5 100644
--- a/gobject/pygsource.c
+++ b/gobject/pygsource.c
@@ -418,14 +418,12 @@ pyg_source_prepare(GSource *source, gint *timeout)
}
ret = PyObject_IsTrue(PyTuple_GET_ITEM(t, 0));
-
- if (ret) {
*timeout = PyInt_AsLong(PyTuple_GET_ITEM(t, 1));
+
if (*timeout == -1 && PyErr_Occurred()) {
ret = FALSE;
goto bail;
}
- }
got_err = FALSE;
diff --git a/tests/test_source.py b/tests/test_source.py
index 5e0f01b..fd5f310 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -62,5 +62,33 @@ class TestSource(unittest.TestCase):
assert self.pos >= 0 and idle.count >= 0
+ def testSourcePrepare(self):
+ # this test may not terminate if prepare() is wrapped incorrectly
+ dispatched = [False]
+ loop = gobject.MainLoop()
+
+ class CustomTimeout(gobject.Source):
+ def prepare(self):
+ return (False, 10)
+
+ def check(self):
+ return True
+
+ def dispatch(self, callback, args):
+ dispatched[0] = True
+
+ loop.quit()
+
+ return False
+
+ source = CustomTimeout()
+
+ source.attach()
+ source.set_callback(dir)
+
+ loop.run()
+
+ assert dispatched[0]
+
if __name__ == '__main__':
unittest.main()