[pypy-commit] pypy stdlib-2.7.8: merge heads
bdkearns
noreply at buildbot.pypy.org
Sun Aug 24 19:37:00 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.8
Changeset: r73029:792f248bd1a4
Date: 2014-08-24 13:36 -0400
http://bitbucket.org/pypy/pypy/changeset/792f248bd1a4/
Log: merge heads
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -452,6 +452,11 @@
# The real comparison
if space.is_w(space.type(w_v), space.type(w_w)):
+ if space.isinstance_w(w_v, space.w_set):
+ raise OperationError(
+ space.w_TypeError,
+ space.wrap("cannot compare sets using cmp()")
+ )
# for object of the same type, prefer __cmp__ over rich comparison.
w_cmp = space.lookup(w_v, '__cmp__')
w_res = _invoke_binop(space, w_cmp, w_v, w_w)
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
@@ -168,11 +168,6 @@
w_currently_in_repr = ec._py_repr = space.newdict()
return setrepr(space, w_currently_in_repr, self)
- def descr_cmp(self, space, w_other):
- # hack hack until we get the expected result
- raise OperationError(space.w_TypeError,
- space.wrap('cannot compare sets using cmp()'))
-
def descr_eq(self, space, w_other):
if isinstance(w_other, W_BaseSetObject):
return space.wrap(self.equals(w_other))
@@ -519,7 +514,6 @@
__init__ = gateway.interp2app(W_BaseSetObject.descr_init),
__repr__ = gateway.interp2app(W_BaseSetObject.descr_repr),
__hash__ = None,
- __cmp__ = gateway.interp2app(W_BaseSetObject.descr_cmp),
# comparison operators
__eq__ = gateway.interp2app(W_BaseSetObject.descr_eq),
@@ -619,7 +613,6 @@
__new__ = gateway.interp2app(W_FrozensetObject.descr_new2),
__repr__ = gateway.interp2app(W_BaseSetObject.descr_repr),
__hash__ = gateway.interp2app(W_FrozensetObject.descr_hash),
- __cmp__ = gateway.interp2app(W_BaseSetObject.descr_cmp),
# comparison operators
__eq__ = gateway.interp2app(W_BaseSetObject.descr_eq),
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
@@ -340,7 +340,7 @@
def test_compare(self):
raises(TypeError, cmp, set('abc'), set('abd'))
assert set('abc') != 'abc'
- raises(TypeError, "set('abc') < 42")
+ assert not set('abc') < 42
assert not (set('abc') < set('def'))
assert not (set('abc') <= frozenset('abd'))
assert not (set('abc') < frozenset('abd'))
@@ -375,6 +375,11 @@
assert set() != set('abc')
assert set('abc') != set('abd')
+ class X(set):
+ pass
+
+ raises(TypeError, cmp, X(), X())
+
def test_libpython_equality(self):
for thetype in [frozenset, set]:
word = "aaaaaaaaawfpasrtarspawparst"
More information about the pypy-commit
mailing list