This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Document SyntaxError args and interpretation for f-string fields
Type: Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: ammar2, docs@python, miss-islington, pablogsal, terry.reedy
Priority: normal Keywords: patch

Created on 2021-06-06 18:08 by terry.reedy, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26562 merged terry.reedy, 2021-06-06 18:17
PR 26569 merged miss-islington, 2021-06-07 01:42
PR 26570 merged terry.reedy, 2021-06-07 02:08
Messages (4)
msg395208 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-06 18:08
Document that SyntaxError args[1] is a tuple of the other attributes and how the meaning of the attributes is adjusted when the syntax error is in an f-string field replacement expression.  Also add compile() to the list of builtins that can raise SyntaxError.

PR to follow immediately.  I wrote most of the text so that it works for 3.9 and 3.10+, with the new end info.  In the example, the main part of the message changed from "invalid syntax" to "invalid syntax. Perhaps you forgot a comma?".  I hid that with '...' but each could be given in the respective versions.  args[1] changes from "('', 1, 4, '(a b)\n')" to "('', 1, 2, '(a b)\n', 1, 5)" and that will have to be changed in a 3.9 backport.

Spinoff from #43705.  I will create a separate issue for using this information in IDLE.
msg395240 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-07 01:42
New changeset 67dfa6f2a508c325715625fe442f2ce20270a8b3 by Terry Jan Reedy in branch 'main':
bpo-44322: Document more SyntaxError details. (GH-26562)
https://github.com/python/cpython/commit/67dfa6f2a508c325715625fe442f2ce20270a8b3
msg395241 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-07 02:09
New changeset 2af690fdb26d0312de056b54ddb113d3c44dee8c by Miss Islington (bot) in branch '3.10':
bpo-44322: Document more SyntaxError details. (GH-26562)
https://github.com/python/cpython/commit/2af690fdb26d0312de056b54ddb113d3c44dee8c
msg395244 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-06-07 02:57
New changeset d5f8bd60e1203a41996b3ee370d6f09389070627 by Terry Jan Reedy in branch '3.9':
[3.9] bpo-44322: Document more SyntaxError details. (GH-26562)
https://github.com/python/cpython/commit/d5f8bd60e1203a41996b3ee370d6f09389070627
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88488
2021-06-07 05:24:11terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-06-07 02:57:56terry.reedysetmessages: + msg395244
2021-06-07 02:09:43terry.reedysetmessages: + msg395241
2021-06-07 02:08:30terry.reedysetpull_requests: + pull_request25160
2021-06-07 01:42:49miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25159
2021-06-07 01:42:40terry.reedysetmessages: + msg395240
2021-06-06 18:17:40terry.reedysetkeywords: + patch
pull_requests: + pull_request25151
2021-06-06 18:08:02terry.reedycreate