Skip to content

Docs: incorrect error message #116563

Closed
Closed

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

Activity

  1. terryjreedy commented on Mar 10, 2024

    @terryjreedy
    Member

    The change happened with the new parser in 3.10. I will change the example and change the text to 'one or more'. The rest is still the same for me also. Thank you for linking to spot of the foul.

  2. added 2 commits that reference this issue on Mar 10, 2024
  3. added 4 commits that reference this issue on Mar 11, 2024
  4. added 2 commits that reference this issue on Mar 11, 2024
  5. added a commit that references this issue on Mar 25, 2024
  6. added a commit that references this issue on Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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