gh-145241: specialize SyntaxError for single trailing-comma with item#145282
gh-145241: specialize SyntaxError for single trailing-comma with item#145282pablogsal merged 5 commits intopython:mainfrom
Conversation
3433bc5 to
4994e57
Compare
There was a problem hiding this comment.
Thanks! I've researched this a bit more, and I think we can make this even better :-)
Sorry for the resulting back-and-forth and not enough research in the issue.
The syntax error happens every time the last with item (could be one or could be multiple overall) has a bare trailing comma and items aren't parenthesized.
We'd want to add cases with multiple items as well and adapt the error message accordingly. I've added suggestions ready for you to apply. Please feel free to pick better phrasing though.
PS Also suggested using RAISE_SYNTAX_ERROR_KNOWN_LOCATION so that the caret ^ points at the faulty trailing comma (right now the caret points at the colon).
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Misc/NEWS.d/next/Core_and_Builtins/2026-02-26-18-00-00.gh-issue-145241.hL2k9Q.rst
Outdated
Show resolved
Hide resolved
…e-145241.hL2k9Q.rst Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
|
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Sorry, @pablogsal, I could not cleanly backport this to |
|
Sorry, @pablogsal, I could not cleanly backport this to |
|
Uhh no, not worth it maybe. |
|
I've requested backports because #142236 (comment), but I'm giving up on that in this case. Too much effort. |
with#145241