Author: Manuel Jacob Branch: remove-dict-smm Changeset: r64147:a7eae675b873 Date: 2013-05-15 12:30 +0200 http://bitbucket.org/pypy/pypy/changeset/a7eae675b873/
Log: Let the missing ordering methods be filled in by __total_ordering__. diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py --- a/pypy/objspace/std/dictmultiobject.py +++ b/pypy/objspace/std/dictmultiobject.py @@ -130,10 +130,6 @@ return space.w_False return space.w_True - def descr_ne(self, space, w_other): - # XXX automatize this - return space.not_(self.descr_eq(space, w_other)) - def descr_lt(self, space, w_other): if not isinstance(w_other, W_DictMultiObject): raise operationerrfmt(space.w_TypeError, @@ -393,9 +389,8 @@ __init__ = gateway.interp2app(W_DictMultiObject.descr_init), __eq__ = gateway.interp2app(W_DictMultiObject.descr_eq), - __ne__ = gateway.interp2app(W_DictMultiObject.descr_ne), __lt__ = gateway.interp2app(W_DictMultiObject.descr_lt), - # XXX other comparison methods? + __total_ordering__ = 'auto', __len__ = gateway.interp2app(W_DictMultiObject.descr_len), __iter__ = gateway.interp2app(W_DictMultiObject.descr_iter), diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py --- a/pypy/objspace/std/test/test_dictmultiobject.py +++ b/pypy/objspace/std/test/test_dictmultiobject.py @@ -408,6 +408,24 @@ assert {'a': 1 } < { 'b': 1} assert {'a': 1, 'x': 2 } < { 'b': 1, 'x': 2} + def test_other_rich_cmp(self): + d1 = {1: 2, 3: 4} + d2 = {1: 2, 3: 4} + d3 = {1: 2, 3: 5} + d4 = {1: 2} + + assert d1 <= d2 + assert d1 <= d3 + assert not d1 <= d4 + + assert not d1 > d2 + assert not d1 > d3 + assert d1 > d4 + + assert d1 >= d2 + assert not d1 >= d3 + assert d1 >= d4 + def test_str_repr(self): assert '{}' == str({}) assert '{1: 2}' == str({1: 2}) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit