Commits

DasIch  committed 9452a00

Added a fallback for itertools product to pycompat for python versions < 2.6

  • Participants
  • Parent commits 83de16c

Comments (0)

Files changed (2)

File sphinx/util/pycompat.py

     # Python 3
     class_types = (type,)
 
+try:
+    from itertools import product
+except ImportError: # python < 2.6
+    # this code has been taken from the python documentation
+    def product(*args, **kwargs):
+        pools = map(tuple, args) * kwargs.get('repeat', 1)
+        result = [[]]
+        for pool in pools:
+            result = [x + [y] for x in result for y in pool]
+        for prod in result:
+            yield tuple(prod)
+
 
 # the ubiquitous "bytes" helper function
 if sys.version_info >= (3, 0):

File sphinx/versioning.py

 from uuid import uuid4
 from operator import itemgetter
 from collections import defaultdict
-from itertools import product
 try:
     from itertools import izip_longest as zip_longest
 except ImportError:
     from itertools import zip_longest
 
+from sphinx.util.pycompat import product
+
 
 # anything below that ratio is considered equal/changed
 VERSIONING_RATIO = 65