I get wrong line in the error message when I use Elpy in emacs (interpreter: ipython). This happens when I select part of my code and use ctrl-c-c to run it in elpy. The error message shows the wrong content. For example:
import numpy as np
a = np.array([1,2,3])
for i in range(20):
a = b
I deliberately write a wrong code. If I run it as a whole, the error message is correct:
In [4]: ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-31bb503ed55c> in <module>()
----> 1 import codecs, os;__pyfile = codecs.open('''/tmp/py14415AqV''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/tmp/py14415AqV''');exec(compile(__code, '''/home/yanza15/test.py''', 'exec'));
/home/yanza15/test.py in <module>()
4
5 for i in range(20):
----> 6 a = b
NameError: name 'b' is not defined
But if I only select a part and use ctrl-c-c to run it:
for i in range(20):
a = b
The error message will be
In [5]: ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-7e398e1dee8c> in <module>()
----> 1 import codecs, os;__pyfile = codecs.open('''/tmp/py14415N0b''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/tmp/py14415N0b''');exec(compile(__code, '''/home/yanza15/test.py''', 'exec'));
/home/yanza15/test.py in <module>()
1 import numpy as np
----> 2
3 a = np.array([1,2,3])
4
5 for i in range(20):
NameError: name 'b' is not defined
The line number in the error message is 2, which means the second line I selected is wrong. But the content it shows is the line 2 in the whole code. That's not I want. How can I customize elpy so that the error message shows the correct position of the code where I'm wrong?
Thanks in advance!