Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#5282 closed defect (fixed)

[with patch; positive review] In %python mode in the notebook, tracebacks are not properly reported

Reported by: wasI Owned by: was
Priority: major Milestone: sage-3.3
Component: interfaces Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by was)

Type

%python
os.chdir(1,2,2)

into a notebook cell in sage <= 3.3.rc0 and you will get this as output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/wstein/.sage/sage_notebook/worksheets/admin/42/code/14.py", line 6, in <module>
    print _support_.syseval(python, ur'''os.chdir(1,2,2)''', '/Users/wstein/.sage/sage_notebook/worksheets/admin/42/cells/35')
  File "/Users/wstein/build/build/sage-3.3.alpha3/local/lib/python2.5/site-packages/sage/server/support.py", line 321, in syseval
    return system.eval(cmd)
TypeError: eval() takes at least 3 arguments (2 given)

That's bad since it's giving a traceback based on an error in the use of the system.eval method by the sage notebook itself in server/support.py!

In Sage mode one gets:

os.chdir(1,2,2)

outputs

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/wstein/.sage/sage_notebook/worksheets/admin/42/code/15.py", line 7, in <module>
    os.chdir(_sage_const_1 ,_sage_const_2 ,_sage_const_2 )
  File "/Users/wstein/build/build/sage-3.3.alpha3/local/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg/", line 1, in <module>
    
TypeError: chdir() takes exactly 1 argument (3 given)

That's much better -- at least it is the right exception. Of course the spurious reference ot SQLAlchemy is yet another bug...

Attachments (1)

trac_5282.patch (11.6 KB) - added by was 13 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 13 years ago by was

  • Description modified (diff)
  • Reporter changed from was to wasI

comment:2 Changed 13 years ago by was

  • Summary changed from In %python mode in the notebook, tracebacks are not properly reported to [with patch; needs review] In %python mode in the notebook, tracebacks are not properly reported

OK, I'm posting a patch that fixes this problem. I improved syseval by getting rid of the weird hack of it just raising an exception when the system doesn't provide the interface it should. This meant fixing many of the interfaces, which had evals that didn't work if a locals var was passed in. I think this improved the quality of those interfaces as well, since many had customized eval methods that didn't properly pass extra options up to the base class, but now do.

Changed 13 years ago by was

comment:3 Changed 13 years ago by mabshoff

  • Summary changed from [with patch; needs review] In %python mode in the notebook, tracebacks are not properly reported to [with patch; positive review] In %python mode in the notebook, tracebacks are not properly reported

Positive review and nice cleanup.

Cheers,

Michael

comment:4 Changed 13 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from new to closed

Merged in Sage 3.3.rc1.

Cheers,

Michael

comment:5 Changed 13 years ago by certik

Nice patch, thanks!

Note: See TracTickets for help on using tickets.