Exception does not show which line raised it
Hi there,
I'm new to sage, and made some sage scripts to improve my python scripts' performances. Then I load my script into a sage session, and run a test function.
When I get exception, it shows me the traceback with functions names only, without the instruction that triggered it. For example :
sage: f.runtest()
Generating keys ...
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-3-abdb981a9bdb> in <module>()
----> 1 f.runtest()
<string> in runtest(self)
<string> in KeyGen(self)
/home/hack4u/Download/SageMath/src/sage/rings/rational.pyx in sage.rings.rational.Rational.__mod__ (/home/hack4u/Download/SageMath/src/build/cythonized/sage/rings/rational.c:22716)()
2541 n = rat.numer() % other
2542 d = rat.denom() % other
-> 2543 d = d.inverse_mod(other)
2544 return (n * d) % other
2545
/home/hack4u/Download/SageMath/src/sage/rings/integer.pyx in sage.rings.integer.Integer.inverse_mod (/home/hack4u/Download/SageMath/src/build/cythonized/sage/rings/integer.c:38530)()
6169 sig_off()
6170 if r == 0:
-> 6171 raise ZeroDivisionError, "Inverse does not exist."
6172 return ans
6173
ZeroDivisionError: Inverse does not exist.
And I have no idea which line in KeyGen
does trigger that ZeroDivisionError
. Any idea ?
I think it's interesting that the traceback isn't longer (maybe use pdb or http://doc.sagemath.org/html/en/refer...). As to your specific question, maybe knowing what the code is would help find where your problem is. You seem to be looking for an inverse modulo a non-prime for something not in the ring of units, maybe you can see where you do that?
In fact you didn't read my question. I don't want to resolve the exception, but I want to know which line raised it in my script. As you can see, I'm forced to make prints all along the code to search to place where there is an error. With the classic Python traceback, I can directly see where the error is :
I did read the question, I'm just saying that as a practical matter that is all I can suggest. I don't know why there isn't a longer traceback, and I agree that is very annoying. Normally it should tell the line but perhaps something about
.sage
versus.py
scripts is the issue.