#7646: preparsing file should start *after* the module docstring (factoring
constants out messed things up)
------------------------------+---------------------------------------------
Reporter: was | Owner: was
Type: defect | Status: new
Priority: major | Milestone: sage-4.3
Component: user interface | Keywords:
Work_issues: | Author:
Upstream: N/A | Reviewer:
Merged: |
------------------------------+---------------------------------------------
{{{
Hello William,
I've done some more snooping
into this, and the preparse_file function is messing up the file by adding
lines of the form
_sage_const_2 = Integer(2); _sage_const_3 = Integer(3)
to the {top} of the file. Thus, in most cases, the function
find_position_right_after_docstring
never really gets to do its thing properly. I've temporarily fixed this by
setting the default value of numeric_literals to False in sage-preparse.
This problem still seems to be around in version 4.2....
Best,
---
Subject: SAGE: is the preparser really supposed to be messing up my module
docstrings?
Hello William,
I poked around a bit in the sage source code, for the preparser, and it
seems
that the intention is not to mess up module docstrings:
file: $SAGE_ROOT/local/bin/sage-preparse, lines: 125ff
-----------------------------------------------------
...
# Put the Sage library include along with a autogen message in the
file.
# It is ** critical ** that we put this after the mdoule docstring,
since
# otherwise the module docstring will disappear.
insert = '%s%s.\nfrom sage.all_cmdline import * # import sage
library\n'%(AUTOGEN_MSG, f)
i = find_position_right_after_module_docstring(G)
...
however, with regard to the subject line, see the sage session below.
$ ./sage-4.0.2/sage
----------------------------------------------------------------------
| Sage Version 4.0.2, Release Date: 2009-06-18 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: cat my_mod.sage
"""
This is the module docstring for my_mod.sage. There is one function
my_func()
and one variable
my_var
"""
def my_func():
return 7
my_var = 8
sage: !./sage-4.0.2/sage -preparse my_mod.sage
sage: cat my_mod.py
# This file was *autogenerated* from the file my_mod.sage.
from sage.all_cmdline import * # import sage library
_sage_const_8 = Integer(8); _sage_const_7 = Integer(7)
"""
This is the module docstring for my_mod.sage. There is one function
my_func()
and one variable
my_var
"""
def my_func():
return _sage_const_7
my_var = _sage_const_8
sage: import my_mod
sage: my_mod?
Type: module
Base Class: <type 'module'>
String Form: <module 'my_mod' from 'my_mod.py'>
Namespace: Interactive
File: /home/defu/my_mod.py
Docstring:
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
sage:
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7646>
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.