Message232582
Code entered with -c seems to be treated the same as code entered at the >>> prompt of the interactive interpreter.
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
In both cases, the offending code is right there to be seen, so I can understand reluctance to echo it. For SyntaxErrors (and only them) echoing the code is needed to have something to point to.
Idle's Shell does what you want.
>>> 1/0
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
1/0
ZeroDivisionError: division by zero
Shell can do this because it has easy, platform-independent access to the tkinter Text widget storing and displaying previously entered code. I presume accessing a system-dependent console history buffer is much harder.
Where the difference really matters is when the error is in previously defined objects.
>>> def f():
... return a
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in f
NameError: name 'a' is not defined
versus (Shell)
>>> def f():
return a
>>> f()
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
f()
File "<pyshell#15>", line 2, in f
return a
NameError: name 'a' is not defined |
|
Date |
User |
Action |
Args |
2014-12-13 01:20:21 | terry.reedy | set | recipients:
+ terry.reedy, pitrou, vstinner, benjamin.peterson, Arfrever, serhiy.storchaka |
2014-12-13 01:20:21 | terry.reedy | set | messageid: <1418433621.44.0.207885213575.issue23035@psf.upfronthosting.co.za> |
2014-12-13 01:20:21 | terry.reedy | link | issue23035 messages |
2014-12-13 01:20:19 | terry.reedy | create | |
|