Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: py3.7 Changeset: r98619:4e018a19da74 Date: 2020-01-31 22:31 +0100 http://bitbucket.org/pypy/pypy/changeset/4e018a19da74/
Log: fix error msg diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py --- a/pypy/objspace/descroperation.py +++ b/pypy/objspace/descroperation.py @@ -598,6 +598,8 @@ left, right = specialnames op = getattr(operator, left) def comparison_impl(space, w_obj1, w_obj2): + w_orig_obj1 = w_obj1 + w_orig_obj2 = w_obj2 w_typ1 = space.type(w_obj1) w_typ2 = space.type(w_obj2) w_left_src, w_left_impl = space.lookup_in_type_where(w_typ1, left) @@ -637,7 +639,7 @@ # if we arrived here, they are unorderable raise oefmt(space.w_TypeError, "'%s' not supported between instances of '%T' and '%T'", - symbol, w_obj1, w_obj2) + symbol, w_orig_obj1, w_orig_obj2) return func_with_new_name(comparison_impl, 'comparison_%s_impl'%left.strip('_')) 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 @@ -343,6 +343,19 @@ raises(TypeError, "0.0 < zz()") raises(TypeError, "0j < zz()") + def test_correct_order_error_msg(self): + class A(object): + def __lt__(self, other): + return NotImplemented + __gt__ = __lt__ + + class B(A): + pass + + with raises(TypeError) as e: + A() < B() + assert str(e.value) == "'<' not supported between instances of 'A' and 'B'" + def test_equality_among_different_types(self): class A(object): pass class zz(object): pass _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit