Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a Python 2.3 incompatibility I overlooked in [5516].

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5517 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fc20eeec47f1bf7b178a0432fa74f54a452b62ce 1 parent 5f5f1d9
@malcolmt malcolmt authored
View
5 django/core/urlresolvers.py
@@ -12,6 +12,11 @@
from django.utils.functional import memoize
import re
+try:
+ reversed
+except NameError:
+ from django.utils.itercompat import reversed # Python 2.3 fallback
+
_resolver_cache = {} # Maps urlconf modules to RegexURLResolver instances.
_callable_cache = {} # Maps view and url pattern names to their view functions.
View
7 django/template/defaulttags.py
@@ -11,12 +11,7 @@
try:
reversed
except NameError:
- # Python 2.3 fallback.
- # From http://www.python.org/doc/current/tut/node11.html
- def reversed(data):
- for index in xrange(len(data)-1, -1, -1):
- yield data[index]
-
+ from django.utils.itercompat import reversed # Python 2.3 fallback
register = Library()
View
6 django/utils/itercompat.py
@@ -45,6 +45,12 @@ def groupby(iterable, keyfunc=None):
l.append(item)
yield lastkey, l
+# Not really in itertools, since it's a builtin in Python 2.4 and later, but it
+# does operate as an iterator.
+def reversed(data):
+ for index in xrange(len(data)-1, -1, -1):
+ yield data[index]
+
if hasattr(itertools, 'tee'):
tee = itertools.tee
else:
Please sign in to comment.
Something went wrong with that request. Please try again.