#20731: shortcut coercion for Integer-Rational operations
-------------------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-7.3
Component: coercion | Resolution:
Keywords: days74 | Merged in:
Authors: Vincent Delecroix | Reviewers: Jeroen Demeyer,
| Travis Scrimshaw
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vdelecroix/20731 | dd2defb5ddf707d2dc5a84419a41fdbcd5c75a30
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Changes (by vbraun):
* status: positive_review => needs_work
Comment:
{{{
sage -t --long src/sage/repl/interpreter.py
**********************************************************************
File "src/sage/repl/interpreter.py", line 77, in sage.repl.interpreter
Failed example:
shell.run_cell('1/0')
Expected:
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call
last)
<ipython-input-...> in <module>()
----> 1 Integer(1)/Integer(0)
<BLANKLINE>
.../src/sage/rings/integer.pyx in sage.rings.integer.Integer.__div__
(build/cythonized/sage/rings/integer.c:...)()
... if type(left) is type(right):
... if mpz_sgn((<Integer>right).value) == 0:
-> ... raise ZeroDivisionError("rational division by
zero")
... x = <Rational> Rational.__new__(Rational)
... mpq_div_zz(x.value, (<Integer>left).value,
(<Integer>right).value)
<BLANKLINE>
ZeroDivisionError: rational division by zero
Got:
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call
last)
<ipython-input-1-6f88eab09598> in <module>()
----> 1 Integer(1)/Integer(0)
<BLANKLINE>
/home/buildslave-sage/slave/sage_git/build/src/sage/rings/integer.pyx
in sage.rings.integer.Integer.__div__ (/home/buildslave-
sage/slave/sage_git/build/src/build/cythonized/sage/rings/integer.c:12882)()
1841 if type(left) is type(right):
1842 if mpz_sgn((<Integer>right).value) == 0:
-> 1843 raise ZeroDivisionError("rational division by
zero")
1844 x = <Rational> Rational.__new__(Rational)
1845 mpq_div_zz(x.value, (<Integer>left).value,
(<Integer>right).value)
<BLANKLINE>
ZeroDivisionError: rational division by zero
**********************************************************************
1 item had failures:
1 of 5 in sage.repl.interpreter
[133 tests, 1 failure, 3.60 s]
}}}
--
Ticket URL: <https://trac.sagemath.org/ticket/20731#comment:44>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.