[New-bugs-announce] [issue40267] Error message differs when an expression is in an fstring

Lysandros Nikolaou report at bugs.python.org
Sun Apr 12 17:59:24 EDT 2020


New submission from Lysandros Nikolaou <lisandrosnik at gmail.com>:

There are cases, where the error message differs, when an expression is being parsed inside an fstring. For example:

>>> f'{x+}'
  File "<fstring>", line 1
    (x+)
       ^
SyntaxError: unexpected EOF while parsing
>>> (x+)
  File "<stdin>", line 1
    (x+)
       ^
SyntaxError: invalid syntax

Or with lambda definitions:

>>> f'{lambda x:x}'
  File "<fstring>", line 1
    (lambda x)
             ^
SyntaxError: unexpected EOF while parsing
>>> (lambda x)
  File "<stdin>", line 1
    (lambda x)
             ^
SyntaxError: invalid syntax

----------
components: Interpreter Core
messages: 366272
nosy: gvanrossum, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Error message differs when an expression is in an fstring
versions: Python 3.9

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


More information about the New-bugs-announce mailing list