diff options
author | shimizukawa <shimizukawa@gmail.com> | 2014-04-29 21:54:25 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2014-04-29 21:54:25 +0900 |
commit | af372f6aceb77cf0586fdb786a674cdfd72c547d (patch) | |
tree | 84954c829424b1ec103b36787e0ca0b7f5488fe8 /sphinx/util | |
parent | 7ffd869ddc9a0b14a441ea31f52347a71e876e20 (diff) | |
download | sphinx-af372f6aceb77cf0586fdb786a674cdfd72c547d.tar.gz |
provide __next__() and use native next() to support py2/py3 in one source. refs #1350.
Diffstat (limited to 'sphinx/util')
-rw-r--r-- | sphinx/util/__init__.py | 8 | ||||
-rw-r--r-- | sphinx/util/tags.py | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 27278b08..a90167bf 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -421,11 +421,13 @@ class PeekableIterator(object): def __iter__(self): return self - def next(self): + def __next__(self): """Return the next item from the iterator.""" if self.remaining: return self.remaining.popleft() - return self._iterator.next() + return next(self._iterator) + + next = __next__ # Python 2 compatibility def push(self, item): """Push the `item` on the internal stack, it will be returned on the @@ -435,6 +437,6 @@ class PeekableIterator(object): def peek(self): """Return the next item without changing the state of the iterator.""" - item = self.next() + item = next(self) self.push(item) return item diff --git a/sphinx/util/tags.py b/sphinx/util/tags.py index 2a9b2a02..d5141587 100644 --- a/sphinx/util/tags.py +++ b/sphinx/util/tags.py @@ -35,9 +35,9 @@ class BooleanParser(Parser): node = nodes.Const(None, lineno=token.lineno) else: node = nodes.Name(token.value, 'load', lineno=token.lineno) - self.stream.next() + next(self.stream) elif token.type == 'lparen': - self.stream.next() + next(self.stream) node = self.parse_expression() self.stream.expect('rparen') else: |