From af509f4c73cec3c7c83db3d36983cd9e075a0e16 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 21 Aug 2010 22:19:50 +0200 Subject: [PATCH] Next is new in 2.6. --- sphinx/util/pycompat.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py index e5a712c91..319312a75 100644 --- a/sphinx/util/pycompat.py +++ b/sphinx/util/pycompat.py @@ -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): # Python >= 2.6 + next = next + from itertools import product try: from itertools import zip_longest # Python 3 name @@ -64,6 +66,11 @@ else: # Python < 2.6 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 # itertools documentation. def product(*args, **kwargs): @@ -94,7 +101,6 @@ else: if sys.version_info >= (2, 5): # Python >= 2.5 base_exception = BaseException - next = next any = any all = all @@ -102,11 +108,6 @@ else: # Python 2.4 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): for i in gen: if not i: