Skip to content

Conversation

@dr-carlos
Copy link
Contributor

@dr-carlos dr-carlos commented Nov 19, 2025

  • BaseExceptionGroup.__repr__ now overrides BaseException.__repr__, using the group's exception tuple instead of the mutable argument passed in.
  • ComplexExtendsException (a private macro in Objects/exceptions.c) now has a parameter to modify the exception's __repr__ and not just its __str__.

📚 Documentation preview 📚: https://cpython-previews--141736.org.readthedocs.build/

@iritkatriel
Copy link
Member

Thanks.

We don't make user-visible changes to builtin types without a PEP, so this PR cannot be merged as is.

We could document current behaviour (i.e., don't mutate the list) if it's not clear from the docs and then consider if we want to change it.

If we do want to change it, maybe it should be to make a shallow copy of the list rather than make it a tuple (so the repr/str won't change and break existing code that relies on current behaviour).

@dr-carlos
Copy link
Contributor Author

Thanks.

We don't make user-visible changes to builtin types without a PEP, so this PR cannot be merged as is.

We could document current behaviour (i.e., don't mutate the list) if it's not clear from the docs and then consider if we want to change it.

If we do want to change it, maybe it should be to make a shallow copy of the list rather than make it a tuple (so the repr/str won't change and break existing code that relies on current behaviour).

Thanks for the quick response! That all makes sense.

Just to clarify - is c87b66b not a very similar change in this release without a PEP? But maybe I'm missing something :)

@iritkatriel
Copy link
Member

If you implement BaseExceptionGroup_repr so that the output doesn't change, then this change makes sense and can be merged and backported.

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Thank you!

@dr-carlos
Copy link
Contributor Author

Is there anything blocking this PR?

I'll create an issue/PR updating docs to use tuples here (as suggested by @iritkatriel) once merged.

@iritkatriel iritkatriel added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Dec 5, 2025
@iritkatriel iritkatriel enabled auto-merge (squash) December 5, 2025 11:07
@dr-carlos
Copy link
Contributor Author

Thanks! Not sure why the Android test is failing; but it seems unrelated to this PR.

@picnixz
Copy link
Member

picnixz commented Dec 7, 2025

We'll need to wait for #142365 to be merged so that we can bypass the flaky tests on iOS and Android

@iritkatriel
Copy link
Member

There are some test failures preventing this being merged.

@iritkatriel iritkatriel merged commit ff2577f into python:main Dec 7, 2025
46 checks passed
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 7, 2025
…eption sequence is mutated (pythonGH-141736)

(cherry picked from commit ff2577f56eb2170ef0afafa90f78c693df7ca562)

Co-authored-by: dr-carlos <[email protected]>
@miss-islington-app
Copy link

Sorry, @dr-carlos and @iritkatriel, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ff2577f56eb2170ef0afafa90f78c693df7ca562 3.13

@bedevere-app
Copy link

bedevere-app bot commented Dec 7, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Dec 7, 2025
@bedevere-app
Copy link

bedevere-app bot commented Dec 7, 2025

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

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 7, 2025
@dr-carlos dr-carlos deleted the exception-group-repr branch December 7, 2025 23:04
iritkatriel pushed a commit that referenced this pull request Dec 8, 2025
…ption sequence is mutated (GH-141736) (#142391)

* [3.13] gh-141732: Fix `ExceptionGroup` repr changing when original exception sequence is mutated (GH-141736)
(cherry picked from commit ff2577f)

Co-authored-by: dr-carlos <[email protected]>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x Fedora Stable Refleaks 3.13 (tier-3) has failed when building commit d768900.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1662/builds/727) and take a look at the build logs.
  4. Check if the failure is related to this commit (d768900) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1662/builds/727

Failed tests:

  • test_import

Test leaking resources:

  • test_import: references
  • test_import: memory blocks

Summary of the results of the build (if available):

==

Click to see traceback logs
TracebackTests.test_exec_failure) ... ok


TracebackTests.test_broken_parent_from) ... ok


TracebackTests.test_exec_failure_nested) ... ok


TracebackTests.test_nonexistent_module_nested) ... ok


TracebackTests.test_broken_parent) ... ok


TracebackTests.test_import_bug) ... ok


TracebackTests.test_unencodable_filename) ... ok


TracebackTests.test_nonexistent_module) ... ok


TracebackTests.test_syntax_error) ... ok


TracebackTests.test_broken_submodule) ... ok


TracebackTests.test_broken_from) ... ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants