On 2016-07-06 22:17, Vincent Delecroix wrote: > Indeed > {{{ > sage: parent(~1) # parent changes > Rational Field > sage: parent(1.inverse_of_unit()) # same parent > Integer Ring > sage: 2.inverse_of_unit() # error > Traceback (most recent call last): > ... > ZeroDivisionError: Inverse does not exist. > }}} > sided note: I would like the above to actually be an `ArithmeticError` > rather than a `ZeroDivisionError`.
I agree that it is in general not a ZeroDivisionError, but that it is a (special) ArithmeticError. Built-in exceptions (from [1]): | +-- ArithmeticError | | +-- FloatingPointError | | +-- OverflowError | | +-- ZeroDivisionError Maybe a class class NotInvertibleError(ArithmeticError) would be suitable; thus one can catch exactly when something is not invertible and not accidentally catch something else (e.g. OverflowError, etc.). (+ Deprecation) Daniel [1] https://docs.python.org/2/library/exceptions.html, bottom -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.