[pygobject] Work around wrong 64 bit constants in GLib Gir



commit 4b460e2eb18b8340fe99252063fdb08b0c222968
Author: Martin Pitt <martinpitt gnome org>
Date:   Wed Oct 24 07:28:10 2012 +0200

    Work around wrong 64 bit constants in GLib Gir
    
    GLib's gir currently has wrong constants for MININT64 and MAXUINT64; explicitly
    set them in an override, until this gets fixed properly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685022

 gi/overrides/GLib.py |    8 ++++++++
 tests/test_gi.py     |    9 +++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py
index 9deb651..7b656e8 100644
--- a/gi/overrides/GLib.py
+++ b/gi/overrides/GLib.py
@@ -539,3 +539,11 @@ class Timeout(Source):
             self.set_priority(priority)
 
 __all__.append('Timeout')
+
+
+# work around wrong constants in GLib GIR, see
+# https://bugzilla.gnome.org/show_bug.cgi?id=685022
+MININT64 = -9223372036854775808
+MAXUINT64 = 18446744073709551615
+__all__.append('MININT64')
+__all__.append('MAXUINT64')
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 51cb6f9..315867a 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -64,6 +64,15 @@ class TestConstant(unittest.TestCase):
     def test_constant_number(self):
         self.assertEqual(CONSTANT_NUMBER, GIMarshallingTests.CONSTANT_NUMBER)
 
+    def test_min_max_int(self):
+        self.assertEqual(GLib.MAXINT32, 2 ** 31 - 1)
+        self.assertEqual(GLib.MININT32, -2 ** 31)
+        self.assertEqual(GLib.MAXUINT32, 2 ** 32 - 1)
+
+        self.assertEqual(GLib.MAXINT64, 2 ** 63 - 1)
+        self.assertEqual(GLib.MININT64, -2 ** 63)
+        self.assertEqual(GLib.MAXUINT64, 2 ** 64 - 1)
+
 
 class TestBoolean(unittest.TestCase):
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]