Tracebacks for exceptions in interactively entered code.

Terry Reedy tjreedy at udel.edu
Mon May 7 15:59:10 EDT 2018


I intend to improve the IDLE doc section on IDLE-console differences.

The following is from standard interactive mode (PSF CPython 3.7.0a4) on 
Windows (Win 10, Command Prompt)

 >>> def f():
...     return 1/0
...
 >>> f()
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 2, in f
ZeroDivisionError: division by zero

Each statement is given the same pseudofile name, "<stdin>", lines are 
numbered within each statement, and the code line is not printed.  As 
far as I remember, this has been the same on Windows since forever, 
though only current versions are relevant to current docs.

Is the above also the same on other systems (linux, Mac)?  I would like 
to know before I say so ;-).

By comparison, IDLE prints

 >>> def f():
	return 1/0

 >>> f()
Traceback (most recent call last):
   File "<pyshell#3>", line 1, in <module>
     f()
   File "<pyshell#2>", line 2, in f
     return 1/0
ZeroDivisionError: division by zero

Each statememt has a different pseudofile name (pyshell is the name 
IDLE's shell module) and the code lines are displayed just as when 
running from a real file.

-- 
Terry Jan Reedy




More information about the Python-list mailing list