summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Kääriäinen <anssi.kaariainen@thl.fi>2012-05-07 12:32:14 -0700
committerAnssi Kääriäinen <anssi.kaariainen@thl.fi>2012-05-07 12:32:14 -0700
commit2e729c6c331982e1e0d439c6e5ba04c99c670029 (patch)
tree34195ca0a95f01e1389cf96ce4a8a09d85f55efc
parent5cbfb48b92cb26a335f9c8c0f79d3390290103e2 (diff)
parent9877e84caaf42b307086dcc62003e1d2e7c80671 (diff)
Merge pull request #48 from akaariai/pull_38_fix
Fixed total_ordering for Python < 2.7.2
-rw-r--r--django/utils/functional.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 86bbed7a7b..5b88c3f3cb 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -1,6 +1,7 @@
import copy
import operator
from functools import wraps, update_wrapper
+import sys
# You can't trivially replace this `functools.partial` because this binds to
@@ -311,11 +312,13 @@ def partition(predicate, values):
results[predicate(item)].append(item)
return results
-try:
+if sys.version_info >= (2,7,2):
from functools import total_ordering
-except ImportError:
- # For Python < 2.7
- # Code borrowed from python 2.7.3 stdlib
+else:
+ # For Python < 2.7.2. Python 2.6 does not have total_ordering, and
+ # total_ordering in 2.7 versions prior to 2.7.2 is buggy. See
+ # http://bugs.python.org/issue10042 for details. For these versions use
+ # code borrowed from Python 2.7.3.
def total_ordering(cls):
"""Class decorator that fills in missing ordering methods"""
convert = {