[pygobject/pygobject-3-4] Fix OverflowError in source_remove()
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-3-4] Fix OverflowError in source_remove()
- Date: Tue, 23 Oct 2012 04:13:55 +0000 (UTC)
commit 76aa96d41d378e3030797d4eb6224fce040a1ed6
Author: Martin Pitt <martinpitt gnome org>
Date: Tue Oct 23 06:12:08 2012 +0200
Fix OverflowError in source_remove()
GSource IDs are unsigned, so we must use 'I' for parsing then, not 'i'.
https://bugzilla.gnome.org/show_bug.cgi?id=684526
gi/_glib/glibmodule.c | 2 +-
tests/test_source.py | 13 ++++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gi/_glib/glibmodule.c b/gi/_glib/glibmodule.c
index 11b97f5..4dea68c 100644
--- a/gi/_glib/glibmodule.c
+++ b/gi/_glib/glibmodule.c
@@ -313,7 +313,7 @@ pyglib_source_remove(PyObject *self, PyObject *args)
{
guint tag;
- if (!PyArg_ParseTuple(args, "i:source_remove", &tag))
+ if (!PyArg_ParseTuple(args, "I:source_remove", &tag))
return NULL;
return PyBool_FromLong(g_source_remove(tag));
diff --git a/tests/test_source.py b/tests/test_source.py
index fe674cd..6e497e1 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -2,7 +2,7 @@
import unittest
-from gi.repository import GLib
+from gi.repository import GLib, GObject
class Idle(GLib.Idle):
@@ -113,6 +113,17 @@ class TestSource(unittest.TestCase):
s = f()
self.assertTrue(s.is_destroyed())
+ def testRemove(self):
+ s = GLib.idle_add(dir)
+ self.assertEqual(GLib.source_remove(s), True)
+ # s is now removed, should fail now
+ self.assertEqual(GLib.source_remove(s), False)
+
+ # accepts large source IDs (they are unsigned)
+ self.assertEqual(GLib.source_remove(GObject.G_MAXINT32), False)
+ self.assertEqual(GLib.source_remove(GObject.G_MAXINT32 + 1), False)
+ self.assertEqual(GLib.source_remove(GObject.G_MAXUINT32), False)
+
class TestTimeout(unittest.TestCase):
def test504337(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]