Skip to content

Docs: incorrect error message #116563

Closed
Closed
@Privat33r-dev

Description

@Privat33r-dev

Documentation

Part 8 of the Python tutorial contains the following example:

>>> while True print('Hello world')
  File "<stdin>", line 1
    while True print('Hello world')
                   ^
SyntaxError: invalid syntax

As tested on Python 3.12 and 3.13, the actual error highlight would be:

>>> while True print('Hello world')
  File "<stdin>", line 1
    while True print('Hello world')
               ^^^^^
SyntaxError: invalid syntax

hence the following description might be inaccurate as well:

The parser repeats the offending line and displays a little ‘arrow’ pointing at the earliest point in the line where the error was detected. The error is caused by (or at least detected at) the token preceding the arrow: in the example, the error is detected at the function print(), since a colon (':') is missing before it. File name and line number are printed so you know where to look in case the input came from a script.

I guess that @pablogsal as an expert in a Python error messages might provide more data on current error handling :)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions