ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 03 Feb 2018 04:47:32 +0100line number of error in .sage filehttps://ask.sagemath.org/question/40891/line-number-of-error-in-sage-file/ When sage reports an error, it reports the line number of the `.py` file where the error occured. I am wondering if there is a way to configure sage so that it instead reports the line number of the code in the `.sage` file that ultimately generated that problematic line in the `.py` file.
This would be useful because it is the `.sage` file that I am actually editing.
This is theoretically possible: other languages and transpilers use sourcemaps to solve this same issue.Tue, 30 Jan 2018 23:47:45 +0100https://ask.sagemath.org/question/40891/line-number-of-error-in-sage-file/Comment by dan_fulea for <p>When sage reports an error, it reports the line number of the <code>.py</code> file where the error occured. I am wondering if there is a way to configure sage so that it instead reports the line number of the code in the <code>.sage</code> file that ultimately generated that problematic line in the <code>.py</code> file.</p>
<p>This would be useful because it is the <code>.sage</code> file that I am actually editing.</p>
<p>This is theoretically possible: other languages and transpilers use sourcemaps to solve this same issue.</p>
https://ask.sagemath.org/question/40891/line-number-of-error-in-sage-file/?comment=40900#post-id-40900What is a `.sage` file and what is a `.py` file?
Does `import traceback`, followed by `traceback.print_exc()` at the sensible places, not give the corresponding information?
Where does which sage process report an error? Command line, interpreter?
Example: File content:
# this sage file will deliver a crash at some point...
import traceback
try:
F = GF(31)
for a in range(31):
E = EllipticCurve( F, [a-3,0] )
print a, E.order()
except Exception:
traceback.print_exc()
Then
sage: load( '~/asksage/asksage/makemecrash.py' )
0 32
1 32
2 32
Traceback (most recent call last):
File "/home/dan/asksage/asksage/makemecrash.py", line 7, in <module>
E = EllipticCurve( F, [a-3,0] )
and so on...Wed, 31 Jan 2018 19:50:17 +0100https://ask.sagemath.org/question/40891/line-number-of-error-in-sage-file/?comment=40900#post-id-40900Comment by ml9nn for <p>When sage reports an error, it reports the line number of the <code>.py</code> file where the error occured. I am wondering if there is a way to configure sage so that it instead reports the line number of the code in the <code>.sage</code> file that ultimately generated that problematic line in the <code>.py</code> file.</p>
<p>This would be useful because it is the <code>.sage</code> file that I am actually editing.</p>
<p>This is theoretically possible: other languages and transpilers use sourcemaps to solve this same issue.</p>
https://ask.sagemath.org/question/40891/line-number-of-error-in-sage-file/?comment=40949#post-id-40949My original file is called `file.sage` (the ".sage file"). When I execute it via the terminal command `sage file.sage`, then the file `file.sage.py` (the ".py file") is automatically generated. I hope this clarifies the issue for you.Sat, 03 Feb 2018 04:47:32 +0100https://ask.sagemath.org/question/40891/line-number-of-error-in-sage-file/?comment=40949#post-id-40949