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-146096: Fix base exception group repr by sergey-miryanov · Pull Request #146141 · python/cpython

Conversation

@sergey-miryanov

@sergey-miryanov sergey-miryanov commented Mar 18, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Fix segfault when calling repr for BaseExceptionGroup.

cc @dr-carlos

  • Issue: Out-of-bounds tuple access in BaseExceptionGroup_repr #146096

Sorry, something went wrong.

Uh oh!

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

dr-carlos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
sergey-miryanov added 3 commits March 19, 2026 01:16
@sergey-miryanov
Fix BaseExceptionGroup repr
2f0e336
@sergey-miryanov
Add tests
007cac7
@sergey-miryanov
Add news entry
4f9a6ba
@sergey-miryanov
sergey-miryanov requested a review from iritkatriel as a code owner March 18, 2026 20:20
@bedevere-app bedevere-app Bot mentioned this pull request Mar 18, 2026
Out-of-bounds tuple access in BaseExceptionGroup_repr #146096
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Mar 18, 2026
@sergey-miryanov
sergey-miryanov requested review from picnixz and removed request for iritkatriel March 18, 2026 20:21
@dr-carlos

dr-carlos commented Mar 18, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Thanks for the fix @sergey-miryanov! All looks good to me.
My apologies for not considering that args was mutable in the first implementation!

It's a pity that we don't preserve the list-like repr (ExceptionGroup('msg', [ValueError()])) in this case. But mutating the args to something without an exceptions list in it seems like a weird enough use case that we can just do this?
If this is something that people actually do (why?), we could just set the self->excs_str in all cases, but that can be quite inefficient and I'd really prefer not to.

sergey-miryanov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

iritkatriel
iritkatriel reviewed Mar 18, 2026
View reviewed changes
Comment thread Objects/exceptions.c
* with self.exceptions. Instead, use self.exceptions for accuracy,
* making it look like self.args[1] for backwards compatibility. */
if (PyList_Check(PyTuple_GET_ITEM(self->args, 1))) {
if (PyTuple_GET_SIZE(self->args) == 2 && PyList_Check(PyTuple_GET_ITEM(self->args, 1))) {

@iritkatriel iritkatriel Mar 18, 2026

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.

Do we need to check that it's a Tuple first?

Sorry, something went wrong.

Uh oh!

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

All reactions

@dr-carlos dr-carlos Mar 18, 2026

Copy link
Copy Markdown
Contributor

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.

No, args is always converted to a tuple in its setter:
https://github.com/sergey-miryanov/cpython/blob/4f9a6ba7ba98a83d5594aacadcddb90696ffd5d7/Objects/exceptions.c#L351-L364

Sorry, something went wrong.

Uh oh!

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

All reactions

@iritkatriel iritkatriel Mar 19, 2026

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.

Could add an assert just so it reads like it makes sense.

Sorry, something went wrong.

Uh oh!

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

All reactions

@sergey-miryanov sergey-miryanov Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

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

iritkatriel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
iritkatriel
iritkatriel approved these changes Mar 19, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Mar 19, 2026
@sergey-miryanov
Add assertion
5fdaa02
@sergey-miryanov

sergey-miryanov commented Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure that failed test related to change.

All reactions

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
Merge branch 'main' into bug/146096-fix-base-exception-group-repr
023c9ba
@iritkatriel
iritkatriel merged commit ced6460 into python:main Mar 19, 2026
50 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 19, 2026
@sergey-miryanov
sergey-miryanov deleted the bug/146096-fix-base-exception-group-repr branch March 19, 2026 11:26
@sergey-miryanov

sergey-miryanov commented Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks all!

All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal pablogsal mentioned this pull request Apr 4, 2026
gh-130273: Fix traceback color output with unicode characters #142529
Merged
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@sergey-miryanov @ljfp
pythonGH-146096: Fix segfault in BaseExceptionGroup repr (python#146141)
a1de9c6
@encukou

encukou commented Sep 3, 2026

Copy link
Copy Markdown
Member

The cause of the segfault, #141732, was backported to 3.13 & 3.14. The reproducer crashes on both:

eg = ExceptionGroup("msg", [ValueError()])
eg.args = ()
# repr of the ExceptionGroup with empty args should not crash
print(repr(eg), "ExceptionGroup('msg', (ValueError(),))")

I'll backport the fix there.

iritkatriel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@encukou encukou added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Sep 3, 2026
@miss-islington-app

miss-islington-app Bot commented Sep 3, 2026

Copy link
Copy Markdown

Thanks @sergey-miryanov for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 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 Sep 3, 2026

Copy link
Copy Markdown

Thanks @sergey-miryanov for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app

bedevere-app Bot commented Sep 3, 2026

Copy link
Copy Markdown

GH-156903 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 3, 2026
@bedevere-app

bedevere-app Bot commented Sep 3, 2026

Copy link
Copy Markdown

GH-156904 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 3, 2026
encukou pushed a commit that referenced this pull request Sep 4, 2026
@miss-islington @sergey-miryanov
[3.14] GH-146096: Fix segfault in BaseExceptionGroup repr (GH-146141) (…
1cb0003
…GH-156904)

(cherry picked from commit ced6460)

Co-authored-by: Sergey Miryanov <[email protected]>
encukou pushed a commit that referenced this pull request Sep 4, 2026
@miss-islington @sergey-miryanov
[3.13] GH-146096: Fix segfault in BaseExceptionGroup repr (GH-146141) (…
9ce6acd
…GH-156903)

(cherry picked from commit ced6460)

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

Reviewers

@iritkatriel iritkatriel iritkatriel approved these changes
@picnixz picnixz Awaiting requested review from picnixz
+1 more reviewer
@dr-carlos dr-carlos dr-carlos left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

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.

5 participants

@sergey-miryanov @dr-carlos @encukou @iritkatriel @kumaraditya303
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.