[issue46441] Caret points to wrong line on 'return yield 42' in REPL

Guido van Rossum report at bugs.python.org
Wed Jan 19 18:07:56 EST 2022


New submission from Guido van Rossum <guido at python.org>:

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

----------
assignee: pablogsal
components: Parser
messages: 410988
nosy: gvanrossum, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Caret points to wrong line on 'return yield 42' in REPL
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46441>
_______________________________________


More information about the Python-bugs-list mailing list