[issue44885] Incorrect exception highlighting for fstring format

2021-08-12 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 4b86c9c5146c339c689830619be9d29b8f7bf417 by Pablo Galindo Salgado 
in branch '3.9':
[3.9] bpo-44885: Correct the ast locations of f-strings with format specs and 
repeated expressions (GH-27729) (GH-27744)
https://github.com/python/cpython/commit/4b86c9c5146c339c689830619be9d29b8f7bf417


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-12 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-12 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset c28c2e1cb0dd5fc8b17514e2c4ee17415af733a4 by Pablo Galindo Salgado 
in branch '3.10':
[3.10] bpo-44885: Correct the ast locations of f-strings with format specs and 
repeated expressions (GH-27729) (GH-27743)
https://github.com/python/cpython/commit/c28c2e1cb0dd5fc8b17514e2c4ee17415af733a4


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-12 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +26222
pull_request: https://github.com/python/cpython/pull/27744

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-12 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +26221
pull_request: https://github.com/python/cpython/pull/27743

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-12 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 8e832fb2a2cb54d7262148b6ec15563dffb48d63 by Pablo Galindo Salgado 
in branch 'main':
bpo-44885: Correct the ast locations of f-strings with format specs and 
repeated expressions (GH-27729)
https://github.com/python/cpython/commit/8e832fb2a2cb54d7262148b6ec15563dffb48d63


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-11 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
pull_requests: +26209
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27729

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-11 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Ha, we have test that knows is broken:

https://github.com/python/cpython/blob/f66d00fdd7e9a333accc6bf0e37173051aaa55d0/Lib/test/test_fstring.py#L217

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-11 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Actually, this has even more problems. Because we are using strstr to find the 
start of the expression in the parent string, if the expression is repeated the 
offsets are incorrectly generated:

For example:

print(f"Here is that {xxx} pesky {xxx} again")

This produces:

...
 FormattedValue(
value=Name(
   id='xxx',
   ctx=Load(),
   lineno=1,
   col_offset=22,
   end_lineno=1,
   end_col_offset=25),
...
 FormattedValue(
value=Name(
   id='',
   ctx=Load(),
   lineno=1,
   col_offset=22,
   end_lineno=1,
   end_col_offset=25),
...

while

print(f"Here is that {xxx} pesky {} again")

(different variables) produces:

...
 FormattedValue(
value=Name(
   id='xxx',
   ctx=Load(),
   lineno=1,
   col_offset=22,
   end_lineno=1,
   end_col_offset=25),
...
 FormattedValue(
value=Name(
   id='',
   ctx=Load(),
   lineno=1,
   col_offset=34,
   end_lineno=1,
   end_col_offset=38),
...

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-11 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

The problem lies here:

https://github.com/python/cpython/blob/f66d00fdd7e9a333accc6bf0e37173051aaa55d0/Parser/string_parser.c#L374-L389

The problem is that the strstr call will fail because the string containing the 
expression doesn't have the formatting part in it, so the offsets never get 
corrected.

--
nosy: +lys.nikolaou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-11 Thread Guido van Rossum


Guido van Rossum  added the comment:

(I originally reported this.)

--
nosy: +gvanrossum

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44885] Incorrect exception highlighting for fstring format

2021-08-11 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

Given this code:

print(f"Here is that pesky {xxx/2:.3f} again")

The traceback prints:

Traceback (most recent call last):
  File "/home/pablogsal/github/python/main/lel.py", line 1, in 
print(f"Here is that pesky {xxx/2:.3f} again")
   ^^^
NameError: name 'xxx' is not defined

Removing the formatting part ":.3f" makes it work as expected

--
components: Interpreter Core
messages: 399372
nosy: BTaskaya, ammar2, pablogsal
priority: normal
severity: normal
status: open
title: Incorrect exception highlighting for fstring format
type: behavior
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com