Ticket #5052 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[with patch, positive review] preparser does not respect leading space in front of "load foo.sage"

Reported by: ddrake Owned by: cwitty
Priority: major Milestone: sage-3.3
Component: misc Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

If you have something like the following in a file:

try:
    load foo.sage
except:
    print 'uh oh'

it gets preparsed to this, and blows up because of the bad indentation:

try:
execfile("foo.py")
except:
    print 'uh oh'

The preparser is not honoring the leading space before the load statement.

Attachments

trac_5052.patch Download (2.8 KB) - added by ddrake 4 years ago.

Change History

Changed 4 years ago by ddrake

comment:1 Changed 4 years ago by ddrake

  • Summary changed from preparser does not respect leading space in front of "load foo.sage" to [with patch, needs review] preparser does not respect leading space in front of "load foo.sage"

comment:2 Changed 4 years ago by ddrake

The problem was in sage-preparse; it ran a lstrip() on the line and never took into consideration the indentation.

I wanted to add some doctests, since as we see here, anything not tested is broken -- do the files in $SAGE_ROOT/local/bin get doctested?

comment:3 Changed 4 years ago by boothby

  • Summary changed from [with patch, needs review] preparser does not respect leading space in front of "load foo.sage" to [with patch, positive review] preparser does not respect leading space in front of "load foo.sage"

works for me

comment:4 Changed 4 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 3.3.alpha3

Note: See TracTickets for help on using tickets.