summaryrefslogtreecommitdiff
path: root/django/utils/itercompat.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-03-31 08:24:29 +0000
committerClaude Paroz <claude@2xlibre.net>2012-03-31 08:24:29 +0000
commit23d34597615d8209de72bd819539a696ba0d1e7f (patch)
tree6d77500c4a347ae495577ecf9e313c349c5df4e9 /django/utils/itercompat.py
parent27322df99527ea2f0a3388261e736746430dcf98 (diff)
Fixed #17965 -- Definitely dropped support for Python 2.5. Thanks jonash for the initial patch and Aymeric Augustin for the review.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17834 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/itercompat.py')
-rw-r--r--django/utils/itercompat.py24
1 files changed, 7 insertions, 17 deletions
diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py
index 82434b7c9b..dd47b7df24 100644
--- a/django/utils/itercompat.py
+++ b/django/utils/itercompat.py
@@ -8,23 +8,6 @@ import __builtin__
import itertools
import warnings
-# Fallback for Python 2.5
-def product(*args, **kwds):
- """
- Taken from http://docs.python.org/library/itertools.html#itertools.product
- """
- # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
- # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
- pools = map(tuple, args) * kwds.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)
-
-if hasattr(itertools, 'product'):
- product = itertools.product
-
def is_iterable(x):
"A implementation independent way of checking for iterables"
try:
@@ -34,6 +17,13 @@ def is_iterable(x):
else:
return True
+def product(*args, **kwds):
+ # PendingDeprecationWarning in 1.5, remove this comment when the Deprecations
+ # will have been advanced for 1.5
+ warnings.warn("django.utils.itercompat.product is deprecated; use the native version instead",
+ PendingDeprecationWarning)
+ return itertools.product(*args, **kwds)
+
def all(iterable):
warnings.warn("django.utils.itercompat.all is deprecated; use the native version instead",
PendingDeprecationWarning)