[pygobject] Allow comparing Gtk.TreePath to None



commit 78ea84cd91392400ebac5a361ef8793bfe928fd0
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Sun Dec 19 23:10:57 2010 +0100

    Allow comparing Gtk.TreePath to None
    
    https://bugzilla.gnome.org/show_bug.cgi?id=637615

 gi/overrides/Gtk.py     |   12 ++++++------
 tests/test_overrides.py |    6 ++++++
 2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index fe382c0..545e165 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -910,22 +910,22 @@ class TreePath(Gtk.TreePath):
         return self.to_string()
 
     def __lt__(self, other):
-        return self.compare(other) < 0
+        return not other is None and self.compare(other) < 0
 
     def __le__(self, other):
-        return self.compare(other) <= 0
+        return not other is None and self.compare(other) <= 0
 
     def __eq__(self, other):
-        return self.compare(other) == 0
+        return not other is None and self.compare(other) == 0
 
     def __ne__(self, other):
-        return self.compare(other) != 0
+        return other is None or self.compare(other) != 0
 
     def __gt__(self, other):
-        return self.compare(other) > 0
+        return other is None or self.compare(other) > 0
 
     def __ge__(self, other):
-        return self.compare(other) >= 0
+        return other is None or self.compare(other) >= 0
 
 TreePath = override(TreePath)
 __all__.append('TreePath')
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index ad9263d..7b1251b 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -494,6 +494,12 @@ class TestGtk(unittest.TestCase):
         p2 = Gtk.TreePath.new_from_string('1:2:3')
         self.assertEqual(p1, p2)
         self.assertEqual(str(p1), '1:2:3')
+        self.assertTrue(p1 != None)
+        self.assertFalse(p1 == None)
+        self.assertTrue(p1 > None)
+        self.assertTrue(p1 >= None)
+        self.assertFalse(p1 < None)
+        self.assertFalse(p1 <= None)
 
     def test_tree_model(self):
         tree_store = Gtk.TreeStore(int, str)



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