mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
use 'next(iter)' instead of 'iter.next()' to support py2/py3 compatibiity. refs #1350.
This commit is contained in:
parent
27ac856300
commit
071fb45a54
@ -177,7 +177,7 @@ class _SelectorContext:
|
||||
|
||||
def find(elem, path):
|
||||
try:
|
||||
return findall(elem, path).next()
|
||||
return next(findall(elem, path))
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
@ -194,17 +194,17 @@ def findall(elem, path):
|
||||
if path[:1] == "/":
|
||||
raise SyntaxError("cannot use absolute path on element")
|
||||
stream = iter(xpath_tokenizer(path))
|
||||
next = stream.next; token = next()
|
||||
next_ = lambda: next(stream); token = next_()
|
||||
selector = []
|
||||
while 1:
|
||||
try:
|
||||
selector.append(ops[token[0]](next, token))
|
||||
selector.append(ops[token[0]](next_, token))
|
||||
except StopIteration:
|
||||
raise SyntaxError("invalid path")
|
||||
try:
|
||||
token = next()
|
||||
token = next_()
|
||||
if token[0] == "/":
|
||||
token = next()
|
||||
token = next_()
|
||||
except StopIteration:
|
||||
break
|
||||
_cache[path] = selector
|
||||
@ -220,7 +220,7 @@ def findall(elem, path):
|
||||
|
||||
def findtext(elem, path, default=None):
|
||||
try:
|
||||
elem = findall(elem, path).next()
|
||||
elem = next(findall(elem, path))
|
||||
return elem.text
|
||||
except StopIteration:
|
||||
return default
|
||||
|
Loading…
Reference in New Issue
Block a user