#11821: sage-preparse: give 'safer' names to .py files
------------------------------------------------+---------------------------
       Reporter:  jhpalmieri                    |         Owner:              
           Type:  defect                        |        Status:  needs_review
       Priority:  major                         |     Milestone:  sage-5.0    
      Component:  scripts                       |    Resolution:              
       Keywords:                                |   Work issues:              
Report Upstream:  N/A                           |     Reviewers:              
        Authors:  John Palmieri                 |     Merged in:              
   Dependencies:  #9739, #10952, #8708, #12069  |      Stopgaps:              
------------------------------------------------+---------------------------
Description changed by jhpalmieri:

Old description:

> If you run "sage new.sage" on a script "new.sage", it creates a preparsed
> file "new.py".  Then when a file in the twisted package tries to import
> the "new" Python module, it ends up importing this preparsed file
> instead, which leads to problems which can be hard to track down.
>
> I can think of several solutions:
>
>  1. hope that users will know not to use names like "new.sage".  This is
> the current state of affairs, and it seems overly optimistic to me.
>  2. give a warning, or fail outright with an error, if the name of the
> file is the same as that of a Python module.
>  3. name the preparsed file something which is less likely to cause a
> clash, for example, turn "file.sage" into "file_preparsed.py".
>  4. don't save the preparsed file at all: write it to stdout, then run
> "sage-python -c <PREPARSED>" on it.
>
> The attached patch implements number 4.
>
> -----
>
> Apply
>
>  - [attachment:trac_11821-preparse.v2.patch] to the scripts repo
>  - [attachment:trac_11821-doctests.patch] to the main Sage repo

New description:

 If you run "sage new.sage" on a script "new.sage", it creates a preparsed
 file "new.py".  Then when a file in the twisted package tries to import
 the "new" Python module, it ends up importing this preparsed file instead,
 which leads to problems which can be hard to track down.

 I can think of several solutions:

  1. hope that users will know not to use names like "new.sage".  This is
 the current state of affairs, and it seems overly optimistic to me.
  2. give a warning, or fail outright with an error, if the name of the
 file is the same as that of a Python module.
  3. name the preparsed file something which is less likely to cause a
 clash, for example, turn "file.sage" into "file_preparsed.py".
  4. don't save the preparsed file at all: write it to stdout, then run
 "sage-python -c <PREPARSED>" on it.

 The attached patch implements number 4.

 -----

 Apply

  - [attachment:trac_11821-root.patch] to the root repo
  - [attachment:trac_11821-preparse.v3.patch] to the scripts repo
  - [attachment:trac_11821-doctests.patch] to the main Sage repo

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11821#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to