Issue41084
Created on 2020-06-22 23:53 by lys.nikolaou, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 21084 | merged | lys.nikolaou, 2020-06-23 15:01 | |
| PR 21188 | merged | miss-islington, 2020-06-27 19:25 | |
| PR 21212 | merged | lys.nikolaou, 2020-06-29 11:13 | |
| Messages (11) | |||
|---|---|---|---|
| msg372134 - (view) | Author: Lysandros Nikolaou (lys.nikolaou) * | Date: 2020-06-22 23:53 | |
It's relatively easy to identify if a SyntaxError occurs when parsing an fstring expression or not. The idea is to slightly change the error message to start with "f-string: " when it does (in the same way in which SyntaxError messages are produced by the hand-written fstring parser). I have a working PR that produces the following:
$ cat a.py
f'{a $ b}'
$ ./python.exe a.py
File "/Users/lysnikolaou/Repositories/cpython/a.py", line 1
(a $ b)
^
SyntaxError: f-string: invalid syntax
Thoughts?
|
|||
| msg372136 - (view) | Author: Eric V. Smith (eric.smith) * | Date: 2020-06-23 00:49 | |
I think it's a good idea. My only reservation would be: if the parsing of f-strings is moved into the parser, would it be possible to maintain the error new messages? |
|||
| msg372150 - (view) | Author: Lysandros Nikolaou (lys.nikolaou) * | Date: 2020-06-23 09:46 | |
> My only reservation would be: if the parsing of f-strings is moved into the parser, would it be possible to maintain the error new messages? Probably without a single change. |
|||
| msg372422 - (view) | Author: Pablo Galindo Salgado (pablogsal) * | Date: 2020-06-26 11:24 | |
New changeset 2e0a920e9eb540654c0bb2298143b00637dc5961 by Lysandros Nikolaou in branch 'master': bpo-41084: Adjust message when an f-string expression causes a SyntaxError (GH-21084) https://github.com/python/cpython/commit/2e0a920e9eb540654c0bb2298143b00637dc5961 |
|||
| msg372471 - (view) | Author: Lysandros Nikolaou (lys.nikolaou) * | Date: 2020-06-27 18:11 | |
Should we maybe backport this to 3.9 as well? |
|||
| msg372472 - (view) | Author: Pablo Galindo Salgado (pablogsal) * | Date: 2020-06-27 18:31 | |
I would say yes unless someone sees an obvious impediment |
|||
| msg372477 - (view) | Author: Eric V. Smith (eric.smith) * | Date: 2020-06-27 19:18 | |
AFAIK, we don't guarantee the stability of error messages, so I think backporting is fine. It's all the better that this is just prefixing something to an existing error message. |
|||
| msg372478 - (view) | Author: miss-islington (miss-islington) | Date: 2020-06-27 19:43 | |
New changeset cb0dc52d37a5cc561ad39bc034afe7db9c461768 by Miss Islington (bot) in branch '3.9': bpo-41084: Adjust message when an f-string expression causes a SyntaxError (GH-21084) https://github.com/python/cpython/commit/cb0dc52d37a5cc561ad39bc034afe7db9c461768 |
|||
| msg372562 - (view) | Author: STINNER Victor (vstinner) * | Date: 2020-06-29 10:56 | |
The change broke the old parser in Python 3.9, I reopen the issue: AMD64 Arch Linux VintageParser 3.9: https://buildbot.python.org/all/#/builders/765/builds/129 FAIL: test_format_specifier_expressions (test.test_fstring.TestCase) (str="f'{4:{/5}}'") FAIL: test_invalid_syntax_error_message (test.test_fstring.TestCase) FAIL: test_lambda (test.test_fstring.TestCase) (str="f'{lambda x:x}'") FAIL: test_parens_in_expressions (test.test_fstring.TestCase) (str="f'{,}'") FAIL: test_parens_in_expressions (test.test_fstring.TestCase) (str="f'{,}'") |
|||
| msg372570 - (view) | Author: Pablo Galindo Salgado (pablogsal) * | Date: 2020-06-29 12:56 | |
New changeset 990efe0fff749773887a50cb1ecb2c5d09263cf8 by Lysandros Nikolaou in branch '3.9': [3.9] bpo-41084: Fix test_fstring failure when using the old parser (GH-21212) https://github.com/python/cpython/commit/990efe0fff749773887a50cb1ecb2c5d09263cf8 |
|||
| msg372572 - (view) | Author: Lysandros Nikolaou (lys.nikolaou) * | Date: 2020-06-29 13:03 | |
Thanks, Victor! The fix is merged, so I'm closing this again. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:32 | admin | set | github: 85256 |
| 2020-06-29 13:03:43 | lys.nikolaou | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2020-06-29 13:03:31 | lys.nikolaou | set | messages: + msg372572 |
| 2020-06-29 12:56:01 | pablogsal | set | messages: + msg372570 |
| 2020-06-29 11:13:46 | lys.nikolaou | set | stage: resolved -> patch review pull_requests: + pull_request20366 |
| 2020-06-29 10:56:08 | vstinner | set | status: closed -> open nosy:
+ vstinner resolution: fixed -> (no value) |
| 2020-06-27 19:43:55 | miss-islington | set | messages: + msg372478 |
| 2020-06-27 19:25:10 | miss-islington | set | nosy:
+ miss-islington pull_requests: + pull_request20342 |
| 2020-06-27 19:18:02 | eric.smith | set | messages: + msg372477 |
| 2020-06-27 18:31:42 | pablogsal | set | messages: + msg372472 |
| 2020-06-27 18:11:37 | lys.nikolaou | set | messages: + msg372471 |
| 2020-06-26 20:42:31 | lys.nikolaou | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2020-06-26 11:24:31 | pablogsal | set | messages: + msg372422 |
| 2020-06-23 15:01:56 | lys.nikolaou | set | keywords:
+ patch stage: patch review pull_requests: + pull_request20250 |
| 2020-06-23 09:46:00 | lys.nikolaou | set | messages: + msg372150 |
| 2020-06-23 00:49:06 | eric.smith | set | messages: + msg372136 |
| 2020-06-22 23:53:42 | lys.nikolaou | create | |