Author: Antonio Cuni <anto.c...@gmail.com> Branch: py3k Changeset: r53052:5522d023cedb Date: 2012-03-01 14:30 +0100 http://bitbucket.org/pypy/pypy/changeset/5522d023cedb/
Log: bah, I broke == for != for all objects which are not identical :-/. Fix it diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -558,6 +558,15 @@ if w_res is not None: return w_res # + # we did not find any special method, let's do the default logic for + # == and != + if left == '__eq__' or left == '__ne__': + # they are not identical, else it would have been caught by the if + # at the top of the function + assert not space.is_w(w_obj1, w_obj2) + return space.wrap(left != '__eq__') + # + # if we arrived here, they are unorderable typename1 = space.type(w_obj1).getname(space) typename2 = space.type(w_obj2).getname(space) raise operationerrfmt(space.w_TypeError, diff --git a/pypy/objspace/test/test_descroperation.py b/pypy/objspace/test/test_descroperation.py --- a/pypy/objspace/test/test_descroperation.py +++ b/pypy/objspace/test/test_descroperation.py @@ -321,6 +321,30 @@ raises(TypeError, "0.0 < zz()") raises(TypeError, "0j < zz()") + def test_equality_among_different_types(self): + class A(object): pass + class zz(object): pass + a = A() + assert a == a + for x, y in [(A(), A()), + (A(), zz()), + (A(), A()), + (A(), None), + (None, A()), + (0, ()), + (0.0, ()), + (0j, ()), + (0, []), + (0.0, []), + (0j, []), + (0, A()), + (0.0, A()), + (0j, A()), + ]: + assert not x == y + assert x != y + + def test_setattrweakref(self): skip("fails, works in cpython") # The issue is that in CPython, none of the built-in types have _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit