summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-06-15 10:10:40 -0400
committerTim Graham <timograham@gmail.com>2015-06-15 13:15:24 -0400
commit4b600ed24488b2d1fc0fd59fc883a84ee745fcf8 (patch)
tree0652c5a7f50fcbcd640bfbee41a9a4bfc217e362
parent47fcbe506c04019a12e16221843e25a52249b1ab (diff)
Removed django.utils.functional.total_ordering()
-rw-r--r--django/contrib/gis/geos/mutable_list.py3
-rw-r--r--django/contrib/gis/maps/google/overlays.py3
-rw-r--r--django/contrib/gis/measure.py2
-rw-r--r--django/core/management/commands/makemessages.py3
-rw-r--r--django/db/migrations/graph.py2
-rw-r--r--django/db/models/fields/__init__.py3
-rw-r--r--django/utils/functional.py36
-rw-r--r--docs/releases/1.9.txt4
8 files changed, 15 insertions, 41 deletions
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py
index 6b60465431..cd639399f4 100644
--- a/django/contrib/gis/geos/mutable_list.py
+++ b/django/contrib/gis/geos/mutable_list.py
@@ -8,8 +8,9 @@ See also http://www.aryehleib.com/MutableLists.html
Author: Aryeh Leib Taurog.
"""
+from functools import total_ordering
+
from django.utils import six
-from django.utils.functional import total_ordering
from django.utils.six.moves import range
diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py
index ac0a6bd315..42f41e3b8e 100644
--- a/django/contrib/gis/maps/google/overlays.py
+++ b/django/contrib/gis/maps/google/overlays.py
@@ -1,11 +1,12 @@
from __future__ import unicode_literals
+from functools import total_ordering
+
from django.contrib.gis.geos import (
LinearRing, LineString, Point, Polygon, fromstr,
)
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
-from django.utils.functional import total_ordering
from django.utils.html import html_safe
diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py
index 527512f71b..52fdf874ca 100644
--- a/django/contrib/gis/measure.py
+++ b/django/contrib/gis/measure.py
@@ -37,9 +37,9 @@ and Geoff Biggs' PhD work on dimensioned units for robotics.
"""
__all__ = ['A', 'Area', 'D', 'Distance']
from decimal import Decimal
+from functools import total_ordering
from django.utils import six
-from django.utils.functional import total_ordering
NUMERIC_TYPES = six.integer_types + (float, Decimal)
AREA_PREFIX = "sq_"
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 094a2d14ff..0f7daf24cf 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -6,6 +6,7 @@ import io
import os
import re
import sys
+from functools import total_ordering
from itertools import dropwhile
import django
@@ -17,7 +18,7 @@ from django.core.management.utils import (
from django.utils import six
from django.utils._os import upath
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.text import get_text_list
diff --git a/django/db/migrations/graph.py b/django/db/migrations/graph.py
index 8d8f41b1eb..f324ba5551 100644
--- a/django/db/migrations/graph.py
+++ b/django/db/migrations/graph.py
@@ -2,11 +2,11 @@ from __future__ import unicode_literals
import warnings
from collections import deque
+from functools import total_ordering
from django.db.migrations.state import ProjectState
from django.utils.datastructures import OrderedSet
from django.utils.encoding import python_2_unicode_compatible
-from django.utils.functional import total_ordering
from .exceptions import CircularDependencyError, NodeNotFoundError
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 568c66f4ac..de13b738d9 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -9,6 +9,7 @@ import math
import uuid
import warnings
from base64 import b64decode, b64encode
+from functools import total_ordering
from django.apps import apps
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.dateparse import parse_date, parse_datetime, parse_time, parse_duration
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 import timezone
from django.utils.deprecation import RemovedInDjango21Warning
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 84f4227784..bade67de46 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -1,7 +1,6 @@
import copy
import operator
-import sys
-from functools import wraps
+from functools import total_ordering, wraps
from django.utils import six
from django.utils.six.moves import copyreg
@@ -385,36 +384,3 @@ def partition(predicate, values):
for item in values:
results[predicate(item)].append(item)
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
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index 38e6723d30..e858838b4e 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -659,6 +659,10 @@ Miscellaneous
* 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:
Features deprecated in 1.9