Permalink
Browse files

Removed Python 2.6 compatibility shim substanced._compat.total_ordering.

  • Loading branch information...
1 parent f7dde83 commit 0f238567c99a3e5ed4e0269c36bd5cd821bd7e61 @mcdonc mcdonc committed Oct 23, 2016
Showing with 5 additions and 33 deletions.
  1. +2 −0 CHANGES.txt
  2. +0 −31 substanced/_compat.py
  3. +2 −1 substanced/catalog/deferred.py
  4. +1 −1 substanced/catalog/tests/test_deferred.py
View
@@ -25,6 +25,8 @@ Next release
would fail with an exception if the name you chose was already
used within the folder. It now shows a flash message and prevents
the change.
+
+- Removed Python 2.6 compatibility shim ``substanced._compat.total_ordering``.
1.0a1 (2015-04-17)
==================
View
@@ -50,37 +50,6 @@ def u(x, encoding='ascii'):
_LETTERS = string.ascii_letters
del string
-try: # pragma: no cover
- from functools import total_ordering
-except ImportError: # pragma: no cover
- # this doesn't exist in Python < 2.7
- def total_ordering(cls): # pragma: no cover
- """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
-
try:
from html import escape # py3
except ImportError: #pragma NO COVER
@@ -6,13 +6,14 @@
import time
import transaction
+from functools import total_ordering
+
from pyramid.settings import asbool
from pyramid.threadlocal import get_current_registry
from transaction.interfaces import ISavepointDataManager
from zope.interface import implementer
from ZODB.POSException import ConflictError
-from .._compat import total_ordering
from ..interfaces import (
IIndexingActionProcessor,
MODE_DEFERRED,
@@ -1305,7 +1305,7 @@ def addBeforeCommitHook(self, fn, args):
self.beforecommit_fn = fn
self.beforecommit_args = args
-from substanced._compat import total_ordering
+from functools import total_ordering
@total_ordering
class DummyAction(object):

0 comments on commit 0f23856

Please sign in to comment.