Tracebacks for exceptions in interactively entered code.
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon May 7 20:20:52 EDT 2018
On Mon, 07 May 2018 15:59:10 -0400, Terry Reedy wrote:
> 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 ;-).
Its the same here:
[steve at ando Python-3.6.4]$ ./python -E
Python 3.6.4 (default, Apr 2 2018, 12:16:49)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def f():
... return 1/x
...
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in f
NameError: name 'x' is not defined
--
Steve
More information about the Python-list
mailing list