Commits

Brian Kearns  committed 792f248 Merge

merge heads

  • Participants
  • Parent commits 6749e16, fc100e8
  • Branches stdlib-2.7.8

Comments (0)

Files changed (3)

File pypy/objspace/descroperation.py

 
         # 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)

File pypy/objspace/std/setobject.py

             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))
     __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),
     __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),

File pypy/objspace/std/test/test_setobject.py

     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'))
         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"