Ticket #508 (closed defect: fixed)
[with patch; positive review] problem with "sage -c"
| Reported by: | was | Owned by: | abergeron |
|---|---|---|---|
| Priority: | major | Milestone: | sage-3.3 |
| Component: | user interface | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
Create any script, say test.sage. The following should work but doesn't:
# sage -c "load test.sage"
Traceback (most recent call last):
File "/home/was/s/local/bin/sage-eval", line 10, in <module>
eval(compile(s,tmp_filename(),'exec'))
File "/home/was/.sage//temp/sage/25215//tmp_0", line 1
load test.sage
^
SyntaxError: invalid syntax
Attachments
Change History
comment:1 Changed 6 years ago by craigcitro
- Component changed from algebraic geometry to user interface
comment:2 Changed 5 years ago by anakha
Why is this supposed to work?
Anyway I did some investigation, and the problem comes from the fact that preparse() doesn't take care of "load test.sage" since that is done by ipython magic usually.
There is very complicated logic in sage-preparse to deal with those that would be inappropriate to reproduce in sage-eval.
Also there is a very simple workaround: sage test.sage
So I vote for 'wontfix' for this bug.
comment:3 Changed 5 years ago by was
So I vote for 'wontfix' for this bug.
Just because you couldn't fix it and there is a workaround doesn't mean it isn't a bug.
And this is still a bug in sage-3.2:
teragon:tmp wstein$ more a.sage
print 2^3
teragon:tmp wstein$ sage -c "load a.sage"
Traceback (most recent call last):
File "/Users/wstein/sage/local/bin/sage-eval", line 10, in <module>
eval(compile(s,tmp_filename(),'exec'))
File "/Users/wstein/.sage//temp/teragon.local/98089//tmp_0", line 1
load a.sage
^
SyntaxError: invalid syntax
comment:4 Changed 5 years ago by anakha
- Summary changed from problem with "sage -c" to [with patch; needs review] problem with "sage -c"
Fixes the problem by emulating load and attach.
It won't work with files that have spaces in their name because sage, sage-sage, sage-run, and various other are not ready to deal with that, yet.
comment:5 Changed 4 years ago by was
- Summary changed from [with patch; needs review] problem with "sage -c" to [with patch; needs work] problem with "sage -c"
This doesn't work because when sage-eval gets run the working directory is local/bin/, so the file test.sage isn't found. I bet you tested this patch with test.sage in SAGE_ROOT/local/bin/, which is the only case when this will work:
teragon-2:sage-3.2 wstein$ more test.sage print "Hi" teragon-2:sage-3.2 wstein$ ./sage -c "load test.sage" /Users/wstein/sage/build/sage-3.2/local/bin/sage-preparse: File test.sage is missing python: can't open file 'test.py': [Errno 2] No such file or directory teragon-2:sage-3.2 wstein$ cp test.sage local/bin/ teragon-2:sage-3.2 wstein$ ./sage -c "load test.sage" Hi
comment:6 Changed 4 years ago by abergeron
- Owner changed from was to abergeron
- Summary changed from [with patch; needs work] problem with "sage -c" to [with patch; needs review] problem with "sage -c"
- Milestone changed from sage-3.4 to sage-3.2.3
It did work with 3.1.4 in other directories. But it doesn't with 3.2 and up as you pointed out.
Last patch fixes this.
comment:8 Changed 4 years ago by GeorgSWeber
- Summary changed from [with patch; needs review] problem with "sage -c" to [with patch; needs review, under review by gsw] problem with "sage -c"
Target time for the review: January 12th
comment:10 Changed 4 years ago by mabshoff
- Summary changed from [with patch; needs review, under review by gsw] problem with "sage -c" to [with patch; needs review] problem with "sage -c"
comment:11 Changed 4 years ago by GeorgSWeber
- Summary changed from [with patch; needs review] problem with "sage -c" to [with patch; positive review] problem with "sage -c"
- Milestone changed from sage-3.4.1 to sage-3.3
Works fine, and looks good to me. (Apply the v2 patch only; tested with Sage 3.2.3)
I adjusted the milestone because this patch does not interfere with the sphinxification.
comment:12 Changed 4 years ago by mabshoff
- Status changed from new to closed
- Resolution set to fixed
Merged in Sage 3.3.alpha0

