Opened 3 years ago

Closed 3 years ago

#24916 closed defect (fixed)

Fix __richcmp__ calls with reversed operands

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-8.2
Component: coercion Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: ef5813a (Commits) Commit: ef5813a9d2f72e91cde914e243981f5354196ea8
Dependencies: Stopgaps:

Description (last modified by jdemeyer)

This code in coerce.pyx has always been wrong:

         if y_is_Element:
             if (<Element>y)._parent.get_flag(Parent_richcmp_element_without_coercion):
                return Py_TYPE(y).tp_richcompare(x, y, op)

because the self argument of __richcmp__ should be of the correct type. So the last line should be replaced by

                return Py_TYPE(y).tp_richcompare(y, x, revop(op))

but this caused some breakage in linear_functions.pyx that needed to be fixed.

Change History (5)

comment:1 Changed 3 years ago by jdemeyer

  • Branch set to u/jdemeyer/fix___richcmp___calls_with_reversed_operands

comment:2 Changed 3 years ago by jdemeyer

  • Commit set to ef5813a9d2f72e91cde914e243981f5354196ea8
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

ef5813aFix __richcmp__ calls with reversed operands

comment:3 Changed 3 years ago by tscrim

  • Reviewers set to Travis Scrimshaw

If the patchbot comes back green, then positive review.

comment:4 Changed 3 years ago by jdemeyer

  • Status changed from needs_review to positive_review

comment:5 Changed 3 years ago by vbraun

  • Branch changed from u/jdemeyer/fix___richcmp___calls_with_reversed_operands to ef5813a9d2f72e91cde914e243981f5354196ea8
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.