Merge pull request #48 from akaariai/pull_38_fix
Fixed total_ordering for Python < 2.7.2
This commit is contained in:
commit
2e729c6c33
|
@ -1,6 +1,7 @@
|
||||||
import copy
|
import copy
|
||||||
import operator
|
import operator
|
||||||
from functools import wraps, update_wrapper
|
from functools import wraps, update_wrapper
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# You can't trivially replace this `functools.partial` because this binds to
|
# 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)
|
results[predicate(item)].append(item)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
try:
|
if sys.version_info >= (2,7,2):
|
||||||
from functools import total_ordering
|
from functools import total_ordering
|
||||||
except ImportError:
|
else:
|
||||||
# For Python < 2.7
|
# For Python < 2.7.2. Python 2.6 does not have total_ordering, and
|
||||||
# Code borrowed from python 2.7.3 stdlib
|
# 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):
|
def total_ordering(cls):
|
||||||
"""Class decorator that fills in missing ordering methods"""
|
"""Class decorator that fills in missing ordering methods"""
|
||||||
convert = {
|
convert = {
|
||||||
|
|
Loading…
Reference in New Issue