Opened 10 years ago

Closed 9 years ago

#13957 closed defect (wontfix)

catch ValueError in comparisons

Reported by: vdelecroix Owned by: vdelecroix
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: coercion Keywords: coercion, comparison
Cc: starosta, slabbe, vdelecroix Merged in:
Authors: Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by vdelecroix)

When element construction by a parent raise a ValueError?, it prevents using the coercion in comparisons.

Note: a coercion should not fail and there is no reason to catch a ValueError?.

Attachments (1)

trac_13957-catch_value_error.patch (2.4 KB) - added by vdelecroix 10 years ago.

Download all attachments as: .zip

Change History (9)

Changed 10 years ago by vdelecroix

comment:1 Changed 10 years ago by slabbe

Can you add a doctest that illustrates the fix ?

comment:2 follow-up: Changed 10 years ago by vdelecroix

No... the only way I found is through a Cython class that inherits from Element. A concrete example is with finite words in #12224. I will look further.

comment:3 Changed 10 years ago by vdelecroix

  • Status changed from new to needs_review

comment:4 follow-up: Changed 9 years ago by tscrim

Sebastien, did you do a review of the patch otherwise?

Best,
Travis

comment:5 in reply to: ↑ 4 Changed 9 years ago by slabbe

Replying to tscrim:

Sebastien, did you do a review of the patch otherwise?

Since I am not familiar with this, I would have prefer to do some test starting from a doctest, thus my question. So, no, I did not do any further review.

Sébastien

comment:6 in reply to: ↑ 2 Changed 9 years ago by tscrim

Replying to vdelecroix:

No... the only way I found is through a Cython class that inherits from Element. A concrete example is with finite words in #12224. I will look further.

I completely forgot about this ticket. Vincent, could you do a minimal/small example by doing the doctest something like

sage: cython("""
....: class Foo(Element):
....:     pass
....: """)
sage: Foo() == Foo()
sage: Foo() < Foo()

Thanks,
Travis

comment:7 Changed 9 years ago by vdelecroix

  • Authors Vincent Delecroix deleted
  • Cc vdelecroix added
  • Description modified (diff)
  • Milestone changed from sage-5.10 to sage-duplicate/invalid/wontfix
  • Status changed from needs_review to positive_review

Hi Travis,

I open the ticket because we made some stupid design decisions for #12224. The point was that we implement a coercion from lists to Words and we raised some ValueError if the content of the list does not match the alphabet. As I learn, it is definitely not what we want from a coercion: a coercion should always succeed.

I close it as wont fix.

comment:8 Changed 9 years ago by jdemeyer

  • Resolution set to wontfix
  • Reviewers set to Vincent Delecroix
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.