[xml] [PATCH] Add methods for python3 iterator



xmlCoreDepthFirstItertor and xmlCoreBreadthFirstItertor only
implement a python2-compatible iterator interface. The necessary
method names (__next__) have been added. They just passthrough
to the python2 method (next).
---
 python/libxml.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/python/libxml.py b/python/libxml.py
index e507e0f..abf0cd4 100644
--- a/python/libxml.py
+++ b/python/libxml.py
@@ -530,6 +530,10 @@ class xmlCoreDepthFirstItertor:
         self.parents = []
     def __iter__(self):
         return self
+    # python3 iterator
+    def __next__(self):
+        return self.next()
+    # python2 iterator
     def next(self):
         while 1:
             if self.node:
@@ -552,6 +556,10 @@ class xmlCoreBreadthFirstItertor:
         self.parents = []
     def __iter__(self):
         return self
+    # python3 iterator
+    def __next__(self):
+        return self.next()
+    # python2 iterator
     def next(self):
         while 1:
             if self.node:
-- 
1.8.5.5



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