Ticket #5324 (closed defect: fixed)
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
Change History
comment:1 Changed 4 years ago by mhansen
- Owner changed from boothby to mhansen
- Status changed from new to assigned
comment:4 Changed 4 years ago by was
Note that the problem isn't just with %time, but with any % modes.
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.

