Make IPython show source code line where exception occurred
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-mode.el |
Fix Released
|
Medium
|
Andreas Roehler |
Bug Description
IPython show source code line where exception occurred35
up vote36 2 down vote37 favorite38
3
I'm irritated by the following output that IPython gives me for an exception:
-------
AttributeError Traceback (most recent call last)
<ipython-
----> 1 parameterStudyP
/Users/
AttributeError: 'tuple' object has no attribute 'values'
A line number from where the exception was raised would be really
helpful. Why isn't it there?
/Users/
What can I do to get more helpful information when an exception is thrown?
summary: |
- Make-ipython-show-source-code-line-where-exception-occurred + Make IPython show source code line where exception occurred |
Changed in python-mode: | |
importance: | Undecided → Medium |
Changed in python-mode: | |
status: | In Progress → Fix Committed |
Changed in python-mode: | |
status: | Fix Committed → Fix Released |
Comment by user unutbu was:
This has to do with how you load the code into IPython. (It would be helpful if you told us how to reproduce your problem.) For example, if I use emacs's M-x py-execute-region, the region of code is copied to a temporary file and the IPython interpreter runs execfile on the temporary file.
When emacs/IPython is used in this manner, there is no useful traceback.
If instead, you import the script and then call the function:
import scd_experiments as SE dyPageRankNibbl e()
SE.parameterStu
then you will see a useful traceback message.
Demo: script.py
def foo():
1/0
If I select the region and call M-x py-execute-region,
In [15]: ## working on region in file /tmp/python- 4126aNj. py...
In [16]: foo() ------- ------- ------- ------- ------- ------- ------- ------- ------- ----- input-16- 624891b0d01a> in <module>()
-------
ZeroDivisionError Traceback (most recent call last)
<ipython-
----> 1 foo()
/tmp/python- 4126aNj. py in foo()
ZeroDivisionError: integer division or modulo by zero
;;;;;;;;;
Should not point to /tmp