Ask Your Question

matlink's profile - activity

2017-10-26 21:06:52 -0500 received badge  Notable Question (source)
2017-06-10 02:15:02 -0500 received badge  Popular Question (source)
2016-03-18 03:12:21 -0500 received badge  Scholar (source)
2016-03-17 13:06:13 -0500 received badge  Nice Question (source)
2016-03-17 04:35:48 -0500 commented question Exception does not show which line raised it

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 :

./fheoti.py
Traceback (most recent call last):
  File "./fheoti.py", line 274, in <module>
    sk,pk = f.KeyGen()
  File "./fheoti.py", line 169, in KeyGen
    1/0
ZeroDivisionError: division by zero
2016-03-16 10:56:39 -0500 received badge  Student (source)
2016-03-16 04:19:03 -0500 asked a question 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 ?