[pygobject] [gi] make overrides work for python 3.x protocols and alias for python 2.x



commit 8b28b1d713df33931e255600ab98feda37a8e02a
Author: John (J5) Palmieri <johnp redhat com>
Date:   Thu Oct 28 13:47:34 2010 -0400

    [gi] make overrides work for python 3.x protocols and alias for python 2.x

 gi/overrides/Gtk.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 93333bc..10a6062 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -522,6 +522,9 @@ class TreeModel(Gtk.TreeModel):
     def __bool__(self):
         return True
 
+    # alias for Python 2.x object protocol
+    __nonzero__ = __bool__
+
     def __getitem__(self, key):
         if isinstance(key, Gtk.TreeIter):
             return TreeModelRow(self, key)
@@ -601,7 +604,6 @@ class TreeModel(Gtk.TreeModel):
         if success:
             return parent_iter
 
-TreeModel.__nonzero__ = TreeModel.__bool__
 TreeModel = override(TreeModel)
 __all__.append('TreeModel')
 
@@ -704,13 +706,16 @@ class TreeModelRowIter(object):
         self.model = model
         self.iter = aiter
 
-    def next(self):
+    def __next__(self):
         if not self.iter:
             raise StopIteration
         row = TreeModelRow(self.model, self.iter)
         self.iter = self.model.iter_next(self.iter)
         return row
 
+    # alias for Python 2.x object protocol
+    next = __next__
+
     def __iter__(self):
         return self
 



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