Ticket #5324 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

notebook -- %time block bug

Reported by: was Owned by: mhansen
Priority: major Milestone: sage-4.2.1
Component: notebook Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

If you create a block like this:

%time 
2+2

in the notebook, then you get the following output:

Traceback (click to the left for traceback)
...
NameError: name 'time' is not defined

IMPORTANT: There is a single space right immediately after %time in the input! Without the space things are fine.

Attachments

sagenb_5324.patch Download (1.4 KB) - added by was 4 years ago.
sagenb_5324-part2.patch Download (687 bytes) - added by was 4 years ago.

Change History

comment:1 Changed 4 years ago by mhansen

  • Owner changed from boothby to mhansen
  • Status changed from new to assigned

comment:2 Changed 4 years ago by jason

mhansen says this is fixed at #5564.

comment:3 Changed 4 years ago by mvngu

Ticket #5564 has been closed because it addresses many issues. The issues it addresses are also considered by other tickets. If anyone is working on this ticket, please refer to #5564 for code and inspiration.

comment:4 Changed 4 years ago by was

Note that the problem isn't just with %time, but with any % modes.

Changed 4 years ago by was

comment:5 Changed 4 years ago by was

  • Status changed from new to needs_review

comment:6 Changed 4 years ago by mhampton

  • Status changed from needs_review to positive_review

Looks good and seems to fix the problem. What's the point of setting i=-1 in the patch? Is that just so i is defined as an integer if text has no elements when reaching the line: return "\n".join(text[i:]).strip()? Setting i = 0 would seem to make slightly more sense, if so. I'm just curious, that doesn't seem like enough of an issue to block a positive review.

comment:7 Changed 4 years ago by was

Is that just so i is defined as an integer if text has no elements when reaching the line: return

Yes. splitlines and split('\n') have different semantics. I changed to splitlines in anticipation of windows.

You're right, using i=0 makes more sense, though of course won't make any difference since in this special case the list we're slicing is empty.

Changed 4 years ago by was

comment:8 Changed 4 years ago by was

  • Status changed from positive_review to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.