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

William Navaraj report at bugs.python.org
Sun Jan 9 23:51:36 EST 2022


William Navaraj <williamnavaraj at gmail.com> added the comment:

The variation in the caret position was also due to the trailing spaces. This is now sorted in this solution with a factored out function to find out the correct offset.
https://github.com/python/cpython/compare/main...williamnavaraj:fix-issue-46275?expand=1

Tested against all of the following cases and it works great:

temp=f"blank ({foo()}"+f"blank ({foo(}"+f"blank ({foo()}"
temp=f"blank*{foo(*blank*foo()*blank*foo()}"+f"({foo(}"+f"blank ({foo(}"
a=foo)+foo()+foo()      
f"blank ({foo(blank ({foo()}) blank foo()})"   
temp=f"blank ({foo)foo2" 
temp=f"blank {foo)"
temp=f"blank {foo)"<Space double triple or more here>
temp=f"blank ({foo)blank ({foo()}) blank foo()})"  yetAnotherBlah
temp=f"blank ({foo)blank ({foo()}) blank foo()})"  yetAnotherBlahWithFurtherSpacesAfter

----------

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


More information about the Python-bugs-list mailing list