[issue41064] Specialise syntax error of **dict in f-string field

2021-03-24 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 8efad61963809d239cac986e3f3bc4cb505ab8fe by Pablo Galindo in 
branch 'master':
bpo-41064: Improve syntax error for invalid usage of '**' in f-strings 
(GH-25006)
https://github.com/python/cpython/commit/8efad61963809d239cac986e3f3bc4cb505ab8fe


--

___
Python tracker 

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



[issue41064] Specialise syntax error of **dict in f-string field

2021-03-24 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



[issue41064] Specialise syntax error of **dict in f-string field

2021-03-23 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> I don't recall if this is really only a "skip leading whitespace" problem, or 
> if there's some other reason they're required.

IIRC, this forces the expression inside to be parsed as an expression. This 
helps the quite a lot the parser. For instance, detecting a bare **x without 
grouping is more difficult, even with the old parser. With parentheses it must 
be an expression so is easier to disambiguate.

--

___
Python tracker 

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



[issue41064] Specialise syntax error of **dict in f-string field

2021-03-23 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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

___
Python tracker 

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



[issue41064] Specialise syntax error of **dict in f-string field

2021-03-23 Thread Eric V. Smith


Eric V. Smith  added the comment:

The parens are added in fstring_compile_expr at 
https://github.com/python/cpython/blob/9feae41c4f04ca27fd2c865807a5caeb50bf4fc4/Parser/string_parser.c#L391

I don't recall if this is really only a "skip leading whitespace" problem, or 
if there's some other reason they're required. If it's just a whitespace issue, 
maybe skipping leading whitespace in fstring_compile_expr is a better idea? One 
of the reasons I originally didn't want to skip leading whitespace is because I 
didn't want to add yet another place where we'd have to maintain a "what 
qualifies as whitespace to the compiler?" decision.

--

___
Python tracker 

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



[issue41064] Specialise syntax error of **dict in f-string field

2021-03-22 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Cressey noted both a compile and IDLE Shell issue.  They must be handled 
separately by different people in separate bpo issues.

The first is about the helpful versus less helpful SyntaxError messages in the 
following (master compiled today).

>>> f'{*x}'
  File "", line 1
(*x)
 ^
SyntaxError: f-string: can't use starred expression here
>>> f'{**x}'
  File "", line 1
(**x)
 ^
SyntaxError: f-string: invalid syntax

The request is make the 2nd message the same or like the 1st.  Seems like it 
should be possible.  I am limiting this bpo issue to this request and opened 
#43600 for fixing IDLE's highlight location.

Pablo, I leave it to you to handle the message enhancement request.  Do you 
know if there is any other situation like this in which the compiled text is 
not the input code?

--
assignee: terry.reedy -> 
components:  -IDLE
title: f-string SyntaxError gives offset within fake line, other issues -> 
Specialise syntax error of **dict in f-string field

___
Python tracker 

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