Removed django.utils.functional.total_ordering()
This commit is contained in:
parent
47fcbe506c
commit
4b600ed244
|
@ -8,8 +8,9 @@ See also http://www.aryehleib.com/MutableLists.html
|
||||||
|
|
||||||
Author: Aryeh Leib Taurog.
|
Author: Aryeh Leib Taurog.
|
||||||
"""
|
"""
|
||||||
|
from functools import total_ordering
|
||||||
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.functional import total_ordering
|
|
||||||
from django.utils.six.moves import range
|
from django.utils.six.moves import range
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from functools import total_ordering
|
||||||
|
|
||||||
from django.contrib.gis.geos import (
|
from django.contrib.gis.geos import (
|
||||||
LinearRing, LineString, Point, Polygon, fromstr,
|
LinearRing, LineString, Point, Polygon, fromstr,
|
||||||
)
|
)
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.utils.functional import total_ordering
|
|
||||||
from django.utils.html import html_safe
|
from django.utils.html import html_safe
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,9 @@ and Geoff Biggs' PhD work on dimensioned units for robotics.
|
||||||
"""
|
"""
|
||||||
__all__ = ['A', 'Area', 'D', 'Distance']
|
__all__ = ['A', 'Area', 'D', 'Distance']
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from functools import total_ordering
|
||||||
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.functional import total_ordering
|
|
||||||
|
|
||||||
NUMERIC_TYPES = six.integer_types + (float, Decimal)
|
NUMERIC_TYPES = six.integer_types + (float, Decimal)
|
||||||
AREA_PREFIX = "sq_"
|
AREA_PREFIX = "sq_"
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
from functools import total_ordering
|
||||||
from itertools import dropwhile
|
from itertools import dropwhile
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
@ -17,7 +18,7 @@ from django.core.management.utils import (
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils._os import upath
|
from django.utils._os import upath
|
||||||
from django.utils.encoding import DEFAULT_LOCALE_ENCODING, force_str
|
from django.utils.encoding import DEFAULT_LOCALE_ENCODING, force_str
|
||||||
from django.utils.functional import cached_property, total_ordering
|
from django.utils.functional import cached_property
|
||||||
from django.utils.jslex import prepare_js_for_gettext
|
from django.utils.jslex import prepare_js_for_gettext
|
||||||
from django.utils.text import get_text_list
|
from django.utils.text import get_text_list
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
from functools import total_ordering
|
||||||
|
|
||||||
from django.db.migrations.state import ProjectState
|
from django.db.migrations.state import ProjectState
|
||||||
from django.utils.datastructures import OrderedSet
|
from django.utils.datastructures import OrderedSet
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.utils.functional import total_ordering
|
|
||||||
|
|
||||||
from .exceptions import CircularDependencyError, NodeNotFoundError
|
from .exceptions import CircularDependencyError, NodeNotFoundError
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import math
|
||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
|
from functools import total_ordering
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
@ -20,7 +21,7 @@ from django.core import exceptions, validators, checks
|
||||||
from django.utils.datastructures import DictWrapper
|
from django.utils.datastructures import DictWrapper
|
||||||
from django.utils.dateparse import parse_date, parse_datetime, parse_time, parse_duration
|
from django.utils.dateparse import parse_date, parse_datetime, parse_time, parse_duration
|
||||||
from django.utils.duration import duration_string
|
from django.utils.duration import duration_string
|
||||||
from django.utils.functional import cached_property, curry, total_ordering, Promise
|
from django.utils.functional import cached_property, curry, Promise
|
||||||
from django.utils.text import capfirst
|
from django.utils.text import capfirst
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.deprecation import RemovedInDjango21Warning
|
from django.utils.deprecation import RemovedInDjango21Warning
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import copy
|
import copy
|
||||||
import operator
|
import operator
|
||||||
import sys
|
from functools import total_ordering, wraps
|
||||||
from functools import wraps
|
|
||||||
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.six.moves import copyreg
|
from django.utils.six.moves import copyreg
|
||||||
|
@ -385,36 +384,3 @@ def partition(predicate, values):
|
||||||
for item in values:
|
for item in values:
|
||||||
results[predicate(item)].append(item)
|
results[predicate(item)].append(item)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
if sys.version_info >= (2, 7, 2):
|
|
||||||
from functools import total_ordering
|
|
||||||
else:
|
|
||||||
# For Python < 2.7.2. total_ordering in 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 = {
|
|
||||||
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
|
|
||||||
('__le__', lambda self, other: self < other or self == other),
|
|
||||||
('__ge__', lambda self, other: not self < other)],
|
|
||||||
'__le__': [('__ge__', lambda self, other: not self <= other or self == other),
|
|
||||||
('__lt__', lambda self, other: self <= other and not self == other),
|
|
||||||
('__gt__', lambda self, other: not self <= other)],
|
|
||||||
'__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
|
|
||||||
('__ge__', lambda self, other: self > other or self == other),
|
|
||||||
('__le__', lambda self, other: not self > other)],
|
|
||||||
'__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
|
|
||||||
('__gt__', lambda self, other: self >= other and not self == other),
|
|
||||||
('__lt__', lambda self, other: not self >= other)]
|
|
||||||
}
|
|
||||||
roots = set(dir(cls)) & set(convert)
|
|
||||||
if not roots:
|
|
||||||
raise ValueError('must define at least one ordering operation: < > <= >=')
|
|
||||||
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
|
|
||||||
for opname, opfunc in convert[root]:
|
|
||||||
if opname not in roots:
|
|
||||||
opfunc.__name__ = opname
|
|
||||||
opfunc.__doc__ = getattr(int, opname).__doc__
|
|
||||||
setattr(cls, opname, opfunc)
|
|
||||||
return cls
|
|
||||||
|
|
|
@ -659,6 +659,10 @@ Miscellaneous
|
||||||
|
|
||||||
* For security hardening, session keys must be at least 8 characters.
|
* For security hardening, session keys must be at least 8 characters.
|
||||||
|
|
||||||
|
* Private function ``django.utils.functional.total_ordering()`` has been
|
||||||
|
removed. It contained a workaround for a ``functools.total_ordering()`` bug
|
||||||
|
in Python versions older than 2.7.3.
|
||||||
|
|
||||||
.. _deprecated-features-1.9:
|
.. _deprecated-features-1.9:
|
||||||
|
|
||||||
Features deprecated in 1.9
|
Features deprecated in 1.9
|
||||||
|
|
Loading…
Reference in New Issue