Ticket #508 (new defect)

Opened 1 year ago

Last modified 1 week ago

[with patch; needs review, under review by gsw] problem with "sage -c"

Reported by: was Assigned to: abergeron
Priority: major Milestone: sage-3.4
Component: user interface Keywords:
Cc:

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

trac_508.patch (0.6 kB) - added by anakha on 10/23/2008 05:35:26 PM.
trac_508v2.patch (0.7 kB) - added by abergeron on 12/23/2008 08:55:20 PM.

Change History

09/06/2007 10:28:29 PM changed by craigcitro

  • component changed from algebraic geometry to user interface.

10/23/2008 04:02:00 PM changed 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.

10/23/2008 04:37:25 PM changed 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

10/23/2008 05:35:26 PM changed by anakha

  • attachment trac_508.patch added.

10/23/2008 05:37:26 PM changed 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.

11/26/2008 11:49:26 PM changed 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

12/23/2008 08:55:20 PM changed by abergeron

  • attachment trac_508v2.patch added.

12/23/2008 08:57:07 PM changed 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.

12/24/2008 03:51:53 AM changed by mabshoff

  • milestone changed from sage-3.2.3 to sage-3.4.

12/29/2008 01:15:08 PM changed 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