Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed total_ordering for Python < 2.7.2

The total_ordering in Python versions prior to 2.7.2 is buggy, and
this caused infinite recursion for Field comparisons on those
versions. Use the borrowed total_ordering for all Python versions
prior to 2.7.2.

The buggy total_ordering was introduced in commit
5cbfb48
  • Loading branch information...
commit 9877e84caaf42b307086dcc62003e1d2e7c80671 1 parent 5cbfb48
Anssi Kääriäinen authored

Showing 1 changed file with 7 additions and 4 deletions. Show diff stats Hide diff stats

  1. 11  django/utils/functional.py
11  django/utils/functional.py
... ...
@@ -1,6 +1,7 @@
1 1
 import copy
2 2
 import operator
3 3
 from functools import wraps, update_wrapper
  4
+import sys
4 5
 
5 6
 
6 7
 # You can't trivially replace this `functools.partial` because this binds to
@@ -311,11 +312,13 @@ def partition(predicate, values):
311 312
         results[predicate(item)].append(item)
312 313
     return results
313 314
 
314  
-try:
  315
+if sys.version_info >= (2,7,2):
315 316
     from functools import total_ordering
316  
-except ImportError:
317  
-    # For Python < 2.7
318  
-    # Code borrowed from python 2.7.3 stdlib
  317
+else:
  318
+    # For Python < 2.7.2. Python 2.6 does not have total_ordering, and
  319
+    # total_ordering in 2.7 versions prior to 2.7.2 is buggy. See
  320
+    # http://bugs.python.org/issue10042 for details. For these versions use
  321
+    # code borrowed from Python 2.7.3.
319 322
     def total_ordering(cls):
320 323
         """Class decorator that fills in missing ordering methods"""
321 324
         convert = {

0 notes on commit 9877e84

Please sign in to comment.
Something went wrong with that request. Please try again.