Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #48 from akaariai/pull_38_fix

Fixed total_ordering for Python < 2.7.2
  • Loading branch information...
commit 2e729c6c331982e1e0d439c6e5ba04c99c670029 2 parents 5cbfb48 + 9877e84
Anssi Kääriäinen authored May 07, 2012

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 2e729c6

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