Author: Alex Gaynor <alex.gay...@gmail.com> Branch: stdlib-2.7.8 Changeset: r72999:0c42f2897971 Date: 2014-08-23 08:18 -0700 http://bitbucket.org/pypy/pypy/changeset/0c42f2897971/
Log: Improved interoperability of set objects diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py --- a/pypy/objspace/std/setobject.py +++ b/pypy/objspace/std/setobject.py @@ -200,8 +200,7 @@ # correct answer here! def descr_lt(self, space, w_other): if not isinstance(w_other, W_BaseSetObject): - raise OperationError(self.space.w_TypeError, - self.space.wrap('can only compare to a set')) + return space.w_NotImplemented if self.length() >= w_other.length(): return space.w_False @@ -210,8 +209,7 @@ def descr_le(self, space, w_other): if not isinstance(w_other, W_BaseSetObject): - raise OperationError(self.space.w_TypeError, - self.space.wrap('can only compare to a set')) + return space.w_NotImplemented if self.length() > w_other.length(): return space.w_False @@ -219,8 +217,7 @@ def descr_gt(self, space, w_other): if not isinstance(w_other, W_BaseSetObject): - raise OperationError(self.space.w_TypeError, - self.space.wrap('can only compare to a set')) + return space.w_NotImplemented if self.length() <= w_other.length(): return space.w_False @@ -229,8 +226,7 @@ def descr_ge(self, space, w_other): if not isinstance(w_other, W_BaseSetObject): - raise OperationError(self.space.w_TypeError, - self.space.wrap('can only compare to a set')) + return space.w_NotImplemented if self.length() < w_other.length(): return space.w_False diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py --- a/pypy/objspace/std/test/test_setobject.py +++ b/pypy/objspace/std/test/test_setobject.py @@ -8,10 +8,8 @@ This file just contains some basic tests that make sure, the implementation is not too wrong. """ -import py.test from pypy.objspace.std.setobject import W_SetObject, W_FrozensetObject, IntegerSetStrategy from pypy.objspace.std.setobject import _initialize_set -from pypy.objspace.std.setobject import newset from pypy.objspace.std.listobject import W_ListObject letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit