I've noticed that some (many) Python-level error messages (e.g., syntax
errors) from Sage 9.5.beta8 fail to give the name of the source file
in which the error occured. For example, a few minutes ago I got this
error message from a Sage code I'm working on:
> Traceback (most recent call last):
>
> File "/usr/local/sage/sage-9.5.beta8/local/var/lib/sage/venv-python3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
> exec(code_obj, self.user_global_ns, self.user_ns)
>
> File "<ipython-input-2-6e41d69a86f4>", line 1, in <module>
> load('setup.sage')
>
> File "sage/misc/persist.pyx", line 173, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2578)
> sage.repl.load.load(filename, globals())
>
> File "/usr/local/sage/sage-9.5.beta8/local/var/lib/sage/venv-python3.7/lib/python3.7/site-packages/sage/repl/load.py", line 272, in load
> exec(preparse_file(f.read()) + "\n", globals)
>
> File "<string>", line 8, in <module>
>
> File "sage/misc/persist.pyx", line 173, in sage.misc.persist.load (build/cythonized/sage/misc/persist.c:2578)
> sage.repl.load.load(filename, globals())
>
> File "/usr/local/sage/sage-9.5.beta8/local/var/lib/sage/venv-python3.7/lib/python3.7/site-packages/sage/repl/load.py", line 272, in load
> exec(preparse_file(f.read()) + "\n", globals)
>
> File "<string>", line 66
> P_xx[a,b] = simplify_expression(
> ^
> IndentationError: expected an indented block
>
> sage:
Notice that the traceback entries mentioning Sage internal files all
include the file name and line number, but the traceback errors for my
own code just say 'File "<string>"', with no useful information about
which of my source-code files the error occured in.
I'm not sure how much of this is Python's fault and how much is Sage's,
but the user experience is not good.
To reproduce this problem, create the following 2 files:
% head error*
==> error1.sage <==
load('error2.sage')
print bad_function(2, 3)
==> error2.sage <==
def bad_function(x,y)
"""
Note the missing ':' at the end of the first line of this file.
This will produce a Sage/python syntax error when this file
is loaded.
"""
return x+y
%
and type
load('error1.sage')
at the sage command prompt.
stay safe and COVID-free,
--
-- "Jonathan Thornburg [remove color- to reply]" <
jthor...@pink-gmail.com>
on the west coast of Canada, eh?
"There was of course no way of knowing whether you were being watched
at any given moment. How often, or on what system, the Thought Police
plugged in on any individual wire was guesswork. It was even conceivable
that they watched everybody all the time." -- George Orwell, "1984"