This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Arfrever, benjamin.peterson, pitrou, serhiy.storchaka, terry.reedy, vstinner
Date 2014-12-13.01:20:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1418433621.44.0.207885213575.issue23035@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014-12-13 01:20:21terry.reedysetrecipients: + terry.reedy, pitrou, vstinner, benjamin.peterson, Arfrever, serhiy.storchaka
2014-12-13 01:20:21terry.reedysetmessageid: <1418433621.44.0.207885213575.issue23035@psf.upfronthosting.co.za>
2014-12-13 01:20:21terry.reedylinkissue23035 messages
2014-12-13 01:20:19terry.reedycreate