Ticket #228 (closed defect: fixed)
[with patch] bug in sage notebook cell parser and promp stripping.
| Reported by: | was | Owned by: | boothby |
|---|---|---|---|
| Priority: | major | Milestone: | sage-2.8.5 |
| Component: | notebook | Keywords: | |
| Cc: | Author(s): | ||
| Report Upstream: | Reviewer(s): | ||
| Merged in: | Work issues: |
Description
On Sun, 28 Jan 2007 15:26:56 -0800, Timothy Clemans <timothy.clemans@gmail.com> wrote: > > Just to show that something bad seems to be happening, I looked up the > source for prime_pi and copied it into a cell and changed the name to > epi. Well I added print epi(300) and got 0. I also added print "Hello" > and got nothing. In another cell I typed prime_pi(300) and got 62. So > I'm sure that there is a bug in SAGE notebook with docstrings in > personal code. You're absolutely right. This is a bug in the SAGE notebook, or rather, and unforseen "feature". In the notebook if an input cell line starts with either "sage:" or ">>>", then the input is viewed as an example that was likely pasted in, and *only* the lines that begin with sage: are evaluated. (The parser that checks for this doesn't take into account triple-quoted strings!) Unfortunately this leads to the following sort of stupid behavior:
def foo(x):
"""
EXAMPLES:
sage: 2+2
4
"""
return x
///
4
foo(5)
///
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/server/sage_notebook/worksheets/_uniqued/code/13.py", line 4, in <module>
exec compile(ur'foo(Integer(5))' + '\n', '', 'single')
File "/home/server/", line 1, in <module>
NameError: name 'foo' is not defined
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

