Ask Your Question

matlink's profile - activity

2021-02-01 12:42:17 +0200 received badge  Famous Question (source)
2017-10-27 04:06:52 +0200 received badge  Notable Question (source)
2017-06-10 09:15:02 +0200 received badge  Popular Question (source)
2016-03-18 09:12:21 +0200 received badge  Scholar (source)
2016-03-17 19:06:13 +0200 received badge  Nice Question (source)
2016-03-17 10:35:48 +0200 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 :

Traceback (most recent call last):
  File "./", line 274, in <module>
    sk,pk = f.KeyGen()
  File "./", line 169, in KeyGen
ZeroDivisionError: division by zero
2016-03-16 16:56:39 +0200 received badge  Student (source)
2016-03-16 10:19:03 +0200 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

/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

ZeroDivisionError: Inverse does not exist.

And I have no idea which line in KeyGen does trigger that ZeroDivisionError. Any idea ?