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.

classification
Title: Incorrect bad token identified in 3.10.1
Type: Stage: resolved
Components: Parser Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: aroberge, lys.nikolaou, pablogsal
Priority: normal Keywords: patch, patch

Created on 2021-12-07 06:11 by aroberge, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29959 merged pablogsal, 2021-12-07 11:25
PR 29959 merged pablogsal, 2021-12-07 11:25
PR 29961 merged pablogsal, 2021-12-07 13:05
Messages (5)
msg407894 - (view) Author: Andre Roberge (aroberge) * Date: 2021-12-07 06:11
In Python 3.10.1, a change occurred compared with 3.10.0 so that an incorrect token is flagged for a SyntaxError.  Also, in 3.11.0a2, the suggestion made about having forgotten a comma is incorrect.


Python 3.10.1
    for x range(4):
                  ^
SyntaxError: invalid syntax

(I no longer have 3.10.0 available but I know from my tests that it was identifying correctly the wrong token.)


Python 3.11.0a2
    for x range(4):
        ^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

Python 3.9.5
    for x range(4):
          ^
SyntaxError: invalid syntax

Python 3.8.10
    for x range(4):
          ^
SyntaxError: invalid syntax

Python 3.7.8
    for x range(4):
              ^
SyntaxError: invalid syntax

Python 3.6.8
    for x range(4):
              ^
SyntaxError: invalid syntax
msg407895 - (view) Author: Andre Roberge (aroberge) * Date: 2021-12-07 06:16
From (https://friendly-traceback.github.io/docs/syntax_tracebacks_en_3.10.html#for-loop-missing-in-operator), this is what was shown for Python 3.10.0

    for x range(4):
        ^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

Same as Python 3.11.0a2.
msg407933 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-12-07 13:02
New changeset 1c7a1c3be08ee911d347fffd2716f3911ba751f9 by Pablo Galindo Salgado in branch 'main':
bpo-46004: Fix error location for loops with invalid targets (GH-29959)
https://github.com/python/cpython/commit/1c7a1c3be08ee911d347fffd2716f3911ba751f9
msg407941 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-12-07 15:23
New changeset c52141200364898818956a73b955f7c04f634dc8 by Pablo Galindo Salgado in branch '3.10':
[3.10] bpo-46004: Fix error location for loops with invalid targets (GH-29959). (GH-29961)
https://github.com/python/cpython/commit/c52141200364898818956a73b955f7c04f634dc8
msg407942 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021-12-07 15:24
>    From (https://friendly-traceback.github.io/docs/syntax_tracebacks_en_3.10.html#for-loop-missing-in-operator), this is what was shown for Python 3.10.0

Yeah, we are not showing that anymore as we only trigger the error when it happens inside collections to avoid many of the false positives we were seeing.

This PR fixes the problem to point to the correct token, but still show "syntax error"
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90162
2021-12-07 15:24:54pablogsalsetkeywords: patch, patch

messages: + msg407942
2021-12-07 15:23:41pablogsalsetmessages: + msg407941
2021-12-07 15:23:40pablogsalsetkeywords: patch, patch
status: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-12-07 13:05:45pablogsalsetpull_requests: + pull_request28186
2021-12-07 13:02:33pablogsalsetmessages: + msg407933
2021-12-07 11:25:25pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28184
2021-12-07 11:25:20pablogsalsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request28183
2021-12-07 06:16:04arobergesetmessages: + msg407895
2021-12-07 06:11:16arobergecreate