GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-145241: specialize SyntaxError for single trailing-comma with item by pablogsal · Pull Request #145282 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Feb 26, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Specialize syntax error for trailing comma of last item in with #145241

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal
pablogsal requested a review from lysnikolaou as a code owner February 26, 2026 21:45
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 26, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 26, 2026
Specialize syntax error for trailing comma of last item in with #145241
Closed
@pablogsal
pythongh-145241: specialize SyntaxError for single trailing-comma wit…
4994e57
…h item
@pablogsal
pablogsal force-pushed the gh-145241-with-trailing-comma-news branch from 3433bc5 to 4994e57 Compare February 26, 2026 21:46
@johnslavik
johnslavik requested review from johnslavik February 26, 2026 22:52
johnslavik
johnslavik requested changes Feb 26, 2026
View reviewed changes

@johnslavik johnslavik left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_syntax.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Grammar/python.gram Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal and others added 3 commits February 28, 2026 01:46
@pablogsal @johnslavik
Update Lib/test/test_syntax.py
af61c31
Co-authored-by: Bartosz Sławecki <[email protected]>
@pablogsal @johnslavik
Update Grammar/python.gram
7a6fcf1
Co-authored-by: Bartosz Sławecki <[email protected]>
@pablogsal
Update parser
16e0169
@pablogsal
pablogsal enabled auto-merge (squash) February 28, 2026 01:47
johnslavik
johnslavik reviewed Feb 28, 2026
View reviewed changes
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-02-26-18-00-00.gh-issue-145241.hL2k9Q.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

johnslavik
johnslavik approved these changes Feb 28, 2026
View reviewed changes
@pablogsal @johnslavik
Update Misc/NEWS.d/next/Core_and_Builtins/2026-02-26-18-00-00.gh-issu…
0aeb220
…e-145241.hL2k9Q.rst

Co-authored-by: Bartosz Sławecki <[email protected]>
@pablogsal
pablogsal merged commit 09e8c38 into python:main Feb 28, 2026
47 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
pablogsal deleted the gh-145241-with-trailing-comma-news branch February 28, 2026 02:24
@bedevere-app bedevere-app Bot removed the awaiting core review label Feb 28, 2026
@johnslavik johnslavik added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Feb 28, 2026
@miss-islington-app

miss-islington-app Bot commented Feb 28, 2026

Copy link
Copy Markdown

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Feb 28, 2026

Copy link
Copy Markdown

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Feb 28, 2026

Copy link
Copy Markdown

Sorry, @pablogsal, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 09e8c382312b145b710dca7072ff2e13fe8c09ab 3.13
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned pablogsal Feb 28, 2026
@miss-islington-app

miss-islington-app Bot commented Feb 28, 2026

Copy link
Copy Markdown

Sorry, @pablogsal, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 09e8c382312b145b710dca7072ff2e13fe8c09ab 3.14
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnslavik

johnslavik commented Feb 28, 2026

Copy link
Copy Markdown
Member

Uhh no, not worth it maybe.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnslavik johnslavik removed needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Feb 28, 2026
@johnslavik

johnslavik commented Feb 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I've requested backports because #142236 (comment), but I'm giving up on that in this case. Too much effort.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
@pablogsal @johnslavik @brijkapadia
pythongh-145241: specialize SyntaxError for single trailing-comma wit…
0d13a6e
…h item (python#145282)

Co-authored-by: Bartosz Sławecki <[email protected]>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@pablogsal @johnslavik @ljfp
pythongh-145241: specialize SyntaxError for single trailing-comma wit…
172eb81
…h item (python#145282)

Co-authored-by: Bartosz Sławecki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@johnslavik johnslavik johnslavik approved these changes
@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@pablogsal pablogsal

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pablogsal @johnslavik
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.