[New-bugs-announce] [issue46275] caret location for syntax error pointing with f-strings

William Navaraj report at bugs.python.org
Wed Jan 5 20:25:48 EST 2022


New submission from William Navaraj <williamnavaraj at gmail.com>:

Currently for non-f-string syntax errors, 
the caret points to the correct location of the syntax errors

Example 1:

```
a=foo)+foo()+foo()

```
    a=foo)+foo()+foo()
         ^
SyntaxError: unmatched ')'


For f-string syntax errors, 
the caret points two locations after the f-string (almost correct location of the f-strings as a whole but will be more helpful as much as possible to point where exactly the syntax error is)

Example 2:

```
temp=f"blank ({foo(}" 

```
    temp=f"blank ({foo(}" 
                          ^
SyntaxError: f-string: closing parenthesis '}' does not match opening parenthesis '('


Example 3:

```
temp=f"blank ({foo)blank ({foo()}) blank foo()})"

```
    temp=f"blank ({foo)blank ({foo()}) blank foo()})"
                                                     ^
SyntaxError: f-string: unmatched ')'

----------
components: Parser
messages: 409813
nosy: lys.nikolaou, pablogsal, williamnavaraj
priority: normal
severity: normal
status: open
title: caret location for syntax error pointing with f-strings
versions: Python 3.11, Python 3.8

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


More information about the New-bugs-announce mailing list