[pygobject/pygobject-2-28] [gi-overrides] special case python 2 keywords that crept in



commit 0d65223992abec46eee7b2b3c76f68da67de4905
Author: John (J5) Palmieri <johnp redhat com>
Date:   Fri Mar 4 11:43:51 2011 -0500

    [gi-overrides] special case python 2 keywords that crept in

 gi/overrides/Gtk.py     |    6 +++++-
 tests/test_overrides.py |    8 ++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 5c4d84d..110b4d1 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -759,7 +759,11 @@ class TreeModel(Gtk.TreeModel):
                 else:
                     raise ValueError('Expected an integer for column %i but got %s' % (column, type(value)))
             elif type_ == GObject.TYPE_BOOLEAN:
-                if isinstance(value, (int, long)):
+                cmp_classes = [int]
+                if sys.version_info < (3, 0):
+                    cmp_classes.append(long)
+
+                if isinstance(value, tuple(cmp_classes)):
                     value = bool(value)
                 else:
                     raise ValueError('Expected a bool for column %i but got %s' % (column, type(value)))
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 83c4944..9234d96 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -7,7 +7,7 @@ import sys
 import os
 sys.path.insert(0, "../")
 
-from compathelper import _long, _unicode
+from compathelper import _long, _unicode, _bytes
 
 from gi.repository import GLib
 from gi.repository import GObject
@@ -715,11 +715,11 @@ class TestGtk(unittest.TestCase):
                                                 i % 2,
                                                 bool(i % 2),
                                                 i,
-                                                sys.maxint + 1,
+                                                9223372036854775808,
                                                 -9223372036854775808,
                                                 0xffffffffffffffff,
                                                 254,
-                                                'a'
+                                                _bytes('a')
                                                 ))
 
         # len gets the number of children in the root node
@@ -754,7 +754,7 @@ class TestGtk(unittest.TestCase):
            uint_ = tree_store.get_value(treeiter, 8)
            self.assertEquals(uint_, i)
            ulong_ = tree_store.get_value(treeiter, 9)
-           self.assertEquals(ulong_, sys.maxint + 1)
+           self.assertEquals(ulong_, 9223372036854775808)
            int64_ = tree_store.get_value(treeiter, 10)
            self.assertEquals(int64_, -9223372036854775808)
            uint64_ = tree_store.get_value(treeiter, 11)



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