New submission from Guido van Rossum <gu...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue46441>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to