Author: Antonio Cuni <anto.c...@gmail.com> Branch: py3k Changeset: r53034:49df6ee6912a Date: 2012-02-29 23:14 +0100 http://bitbucket.org/pypy/pypy/changeset/49df6ee6912a/
Log: kill the __cmp__ multimethod diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -1566,7 +1566,6 @@ ('ne', '!=', 2, ['__ne__', '__ne__']), ('gt', '>', 2, ['__gt__', '__lt__']), ('ge', '>=', 2, ['__ge__', '__le__']), - ('cmp', 'cmp', 2, ['__cmp__']), # rich cmps preferred ('contains', 'contains', 2, ['__contains__']), ('iter', 'iter', 1, ['__iter__']), ('next', 'next', 1, ['__next__']), diff --git a/pypy/interpreter/nestedscope.py b/pypy/interpreter/nestedscope.py --- a/pypy/interpreter/nestedscope.py +++ b/pypy/interpreter/nestedscope.py @@ -32,6 +32,7 @@ self.w_value = None def descr__cmp__(self, space, w_other): + # XXX fix me, cmp is gone other = space.interpclass_w(w_other) if not isinstance(other, Cell): return space.w_NotImplemented diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -887,7 +887,6 @@ GeneratorIterator.typedef.acceptable_as_base_class = False Cell.typedef = TypeDef("cell", - __cmp__ = interp2app(Cell.descr__cmp__), __hash__ = None, __reduce__ = interp2app(Cell.descr__reduce__), __setstate__ = interp2app(Cell.descr__setstate__), diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -440,9 +440,6 @@ if w_del is not None: space.get_and_call_function(w_del, w_obj) - def cmp(space, w_v, w_w): - raise NotImplementedError - def issubtype(space, w_sub, w_type): return space._type_issubtype(w_sub, w_type) diff --git a/pypy/objspace/flow/operation.py b/pypy/objspace/flow/operation.py --- a/pypy/objspace/flow/operation.py +++ b/pypy/objspace/flow/operation.py @@ -219,7 +219,6 @@ ('inplace_and', inplace_and), ('inplace_or', inplace_or), ('inplace_xor', inplace_xor), - ('cmp', cmp), ('iter', iter), ('next', next), ('get', get), diff --git a/pypy/objspace/std/builtinshortcut.py b/pypy/objspace/std/builtinshortcut.py --- a/pypy/objspace/std/builtinshortcut.py +++ b/pypy/objspace/std/builtinshortcut.py @@ -36,7 +36,7 @@ 'get', 'set', 'delete', # uncommon (except on functions) 'delitem', 'trunc', # rare stuff? 'abs', # rare stuff? - 'pos', 'divmod', 'cmp', # rare stuff? + 'pos', 'divmod', # rare stuff? 'float', 'long', # rare stuff? 'isinstance', 'issubtype', ] 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 @@ -605,15 +605,6 @@ iter__Frozenset = iter__Set -def cmp__Set_settypedef(space, w_left, w_other): - # hack hack until we get the expected result - raise OperationError(space.w_TypeError, - space.wrap('cannot compare sets using cmp()')) - -cmp__Set_frozensettypedef = cmp__Set_settypedef -cmp__Frozenset_settypedef = cmp__Set_settypedef -cmp__Frozenset_frozensettypedef = cmp__Set_settypedef - init_signature = Signature(['some_iterable'], None, None) init_defaults = [None] def init__Set(space, w_set, __args__): diff --git a/pypy/objspace/std/test/test_identitydict.py b/pypy/objspace/std/test/test_identitydict.py --- a/pypy/objspace/std/test/test_identitydict.py +++ b/pypy/objspace/std/test/test_identitydict.py @@ -24,10 +24,6 @@ def __eq__(self, other): return True - class CustomCmp (object): - def __cmp__(self, other): - return 0 - class CustomHash(object): def __hash__(self): return 0 @@ -35,17 +31,11 @@ class TypeSubclass(type): pass - class TypeSubclassCustomCmp(type): - def __cmp__(self, other): - return 0 - assert self.compares_by_identity(Plain) assert not self.compares_by_identity(CustomEq) - assert not self.compares_by_identity(CustomCmp) assert not self.compares_by_identity(CustomHash) assert self.compares_by_identity(type) assert self.compares_by_identity(TypeSubclass) - assert not self.compares_by_identity(TypeSubclassCustomCmp) def test_modify_class(self): class X(object): diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py --- a/pypy/objspace/std/test/test_intobject.py +++ b/pypy/objspace/std/test/test_intobject.py @@ -453,14 +453,6 @@ def test_getnewargs(self): assert 0 .__getnewargs__() == (0,) - - def test_cmp(self): - skip("This is a 'wont fix' case") - # We don't have __cmp__, we consistently have __eq__ & the others - # instead. In CPython some types have __cmp__ and some types have - # __eq__ & the others. - assert 1 .__cmp__ - assert int .__cmp__ def test_bit_length(self): for val, bits in [ 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 @@ -97,7 +97,6 @@ assert d == a def test_compare(self): - raises(TypeError, cmp, set('abc'), set('abd')) assert set('abc') != 'abc' raises(TypeError, "set('abc') < 42") assert not (set('abc') < set('def')) diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -176,8 +176,7 @@ # ^^^ conservative default, fixed during real usage if space.config.objspace.std.withidentitydict: - if (key is None or key == '__eq__' or - key == '__cmp__' or key == '__hash__'): + if (key is None or key == '__eq__' or key == '__hash__'): w_self.compares_by_identity_status = UNKNOWN if space.config.objspace.std.newshortcut: @@ -242,7 +241,6 @@ my_eq = w_self.lookup('__eq__') overrides_eq = (my_eq and my_eq is not type_eq(w_self.space)) overrides_eq_cmp_or_hash = (overrides_eq or - w_self.lookup('__cmp__') or w_self.lookup('__hash__') is not default_hash) if overrides_eq_cmp_or_hash: w_self.compares_by_identity_status = OVERRIDES_EQ_CMP_OR_HASH diff --git a/pypy/objspace/test/test_descriptor.py b/pypy/objspace/test/test_descriptor.py --- a/pypy/objspace/test/test_descriptor.py +++ b/pypy/objspace/test/test_descriptor.py @@ -112,11 +112,6 @@ def __eq__(self, other): pass raises(TypeError, "hash(B())") # because we define __eq__ but not __hash__ - # same as above for __cmp__ - class C(object): - def __cmp__(self, other): pass - hash(C()) - class E(object): def __hash__(self): return "something" _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit