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: Caret points to wrong line on 'return yield 42' in REPL
Type: Stage: resolved
Components: Parser Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pablogsal Nosy List: BTaskaya, gvanrossum, lys.nikolaou, pablogsal
Priority: normal Keywords: patch

Created on 2022-01-19 23:07 by gvanrossum, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30718 merged pablogsal, 2022-01-20 12:20
PR 30720 merged BTaskaya, 2022-01-20 16:03
Messages (4)
msg410988 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2022-01-19 23:07
This seems to happen in 3.11 in the REPL only.

>>> def f():
...   print(0)
...   return yield 42
  File "<stdin>", line 3
    def f():
            ^
SyntaxError: invalid syntax

Note that running it from a file gives the expected output:

PS C:\Users\gvanrossum\cpython> py -3.10 .\t.py
  File "C:\Users\gvanrossum\cpython\t.py", line 3
    return yield 42
           ^^^^^
SyntaxError: invalid syntax

as does the 3.10 REPL:

>>> def f():
...   print(0)
...   return yield 42
  File "<stdin>", line 3
    return yield 42
           ^^^^^
SyntaxError: invalid syntax
msg411028 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-01-20 15:34
Thanks for the bug report, Guido!

Everything should be ok now
msg411034 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2022-01-20 16:35
Thanks for the quick fix!
msg411044 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2022-01-20 20:07
New changeset 30fb6d073d9ca00dff8e4155c523cdfa63abab6b by Batuhan Taskaya in branch 'main':
bpo-46441: Add a boilerplate to test syntax errors in interactive mode (GH-30720)
https://github.com/python/cpython/commit/30fb6d073d9ca00dff8e4155c523cdfa63abab6b
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90599
2022-01-20 20:07:46BTaskayasetmessages: + msg411044
2022-01-20 16:35:31gvanrossumsetmessages: + msg411034
2022-01-20 16:03:01BTaskayasetnosy: + BTaskaya

pull_requests: + pull_request28911
2022-01-20 15:34:42pablogsalsetstatus: open -> closed
resolution: fixed
messages: + msg411028

stage: patch review -> resolved
2022-01-20 12:20:39pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28909
2022-01-19 23:07:56gvanrossumcreate