mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Next is new in 2.6.
This commit is contained in:
parent
867b421178
commit
af509f4c73
@ -50,10 +50,12 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Missing itertools in Python < 2.6
|
# Missing builtins and itertools in Python < 2.6
|
||||||
|
|
||||||
if sys.version_info >= (2, 6):
|
if sys.version_info >= (2, 6):
|
||||||
# Python >= 2.6
|
# Python >= 2.6
|
||||||
|
next = next
|
||||||
|
|
||||||
from itertools import product
|
from itertools import product
|
||||||
try:
|
try:
|
||||||
from itertools import zip_longest # Python 3 name
|
from itertools import zip_longest # Python 3 name
|
||||||
@ -64,6 +66,11 @@ else:
|
|||||||
# Python < 2.6
|
# Python < 2.6
|
||||||
from itertools import izip, repeat, chain
|
from itertools import izip, repeat, chain
|
||||||
|
|
||||||
|
# this is on Python 2, where the method is called "next" (it is refactored
|
||||||
|
# to __next__ by 2to3, but in that case never executed)
|
||||||
|
def next(iterator):
|
||||||
|
return iterator.next()
|
||||||
|
|
||||||
# These replacement functions have been taken from the Python 2.6
|
# These replacement functions have been taken from the Python 2.6
|
||||||
# itertools documentation.
|
# itertools documentation.
|
||||||
def product(*args, **kwargs):
|
def product(*args, **kwargs):
|
||||||
@ -94,7 +101,6 @@ else:
|
|||||||
if sys.version_info >= (2, 5):
|
if sys.version_info >= (2, 5):
|
||||||
# Python >= 2.5
|
# Python >= 2.5
|
||||||
base_exception = BaseException
|
base_exception = BaseException
|
||||||
next = next
|
|
||||||
any = any
|
any = any
|
||||||
all = all
|
all = all
|
||||||
|
|
||||||
@ -102,11 +108,6 @@ else:
|
|||||||
# Python 2.4
|
# Python 2.4
|
||||||
base_exception = Exception
|
base_exception = Exception
|
||||||
|
|
||||||
# this is on Python 2, where the method is called "next" (it is refactored
|
|
||||||
# to __next__ by 2to3, but in that case never executed)
|
|
||||||
def next(iterator):
|
|
||||||
return iterator.next()
|
|
||||||
|
|
||||||
def all(gen):
|
def all(gen):
|
||||||
for i in gen:
|
for i in gen:
|
||||||
if not i:
|
if not i:
|
||||||
|
Loading…
Reference in New Issue
Block a user