Ticket #228 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

[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

ncalexan-228-v2.hg Download (1.1 KB) - added by ncalexan 3 years ago.

Change History

Changed 3 years ago by TimothyClemans

  • status changed from new to closed
  • resolution set to fixed

Changed 3 years ago by TimothyClemans

  • status changed from closed to reopened
  • resolution fixed deleted

Reopen ticket because a patch wasn't created and approved.

Changed 3 years ago by TimothyClemans

  • milestone set to sage-2.9

Changed 3 years ago by ncalexan

Changed 3 years ago by ncalexan

The attached patch addresses this issue by only considering input examples if it starts with a prompt (sage: or >>>).

Changed 3 years ago by ncalexan

  • summary changed from bug in sage notebook cell parser and promp stripping. to [with patch] bug in sage notebook cell parser and promp stripping.
  • milestone changed from sage-2.9 to sage-2.8.4.3

Changed 3 years ago by was

  • status changed from reopened to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.