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 — `ExceptionGroup` repr is misleading if original exception sequence is mutated · Issue #141732 · python/cpython

ExceptionGroup repr is misleading if original exception sequence is mutated #141732

New issue
Copy link
New issue
Copy link
Closed
Closed
ExceptionGroup repr is misleading if original exception sequence is mutated#141732
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@gschaffner
gschaffner
opened on Nov 19, 2025
Issue body actions

Bug report

Bug description:

The exception listing in repr(exc_grp) diverges from exc_grp.exceptions when the initial sequence of exceptions passed to the constructor has been mutated.

Expected behavior: The exceptions listed in repr(exc_grp) match exc_grp.exceptions, which is immutable.

Reproducer:

exceptions = list[Exception]()
exceptions.append(ValueError())
exc_grp = ExceptionGroup("", exceptions)
print(f"{exc_grp.exceptions=!r}")
print(f"{exc_grp=!r}")
print()
exceptions.clear()
print(f"{exc_grp.exceptions=!r}")
print(f"{exc_grp=!r}")

Output:

exc_grp.exceptions=(ValueError(),)
exc_grp=ExceptionGroup('', [ValueError()])

exc_grp.exceptions=(ValueError(),)
exc_grp=ExceptionGroup('', [])

Expected output:

exc_grp.exceptions=(ValueError(),)
exc_grp=ExceptionGroup('', [ValueError()])

exc_grp.exceptions=(ValueError(),)
exc_grp=ExceptionGroup('', [ValueError()])

CPython versions tested on:

3.11, 3.12, 3.13, 3.14

Operating systems tested on:

Linux

Linked PRs

  • gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated #141736
  • [3.14] gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (GH-141736) #142388
  • [3.13] gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (GH-141736) #142391
  • [3.14] gh-141732: Fix ExceptionGroup repr changing when original exception sequence is mutated (GH-141736) #144445

Activity

  1. gschaffner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 19, 2025
  2. gschaffner commented on Nov 19, 2025

    @gschaffner
    gschaffner
    on Nov 19, 2025
    Author
    More actions

    I noticed that PyPy behaves the way I expected here; they use self.exceptions in BaseExceptionGroup.__repr__ instead of self.args[1]:

    https://github.com/pypy/pypy/blob/release-pypy3.11-v7.3.20/pypy/module/exceptions/app_group.py#L92-L93

    On CPython, it looks like BaseExceptionGroup.__repr__ resolves to BaseException.__repr__, so the repr ends up using self.args[1] instead of self.exceptions.

    I skimmed the PEP and didn't see anything that indicated that either repr implementation is in violation of the PEP.

    Reacted by dr-carlos
  3. dr-carlos commented on Nov 19, 2025

    @dr-carlos
    dr-carlos
    on Nov 19, 2025
    Contributor
    More actions

    I skimmed the PEP and didn't see anything that indicated that either repr implementation is in violation of the PEP.

    The PEP does reference the repr() of ExceptionGroups but not explicitly specify anything:

    >>> try:
    ...     raise ExceptionGroup("problem", [BlockingIOError()])
    ... except* OSError as e:   # Would catch the error
    ...     print(repr(e))
    ... except* BlockingIOError: # Would never run
    ...     print('never')
    ...
    ExceptionGroup('problem', [BlockingIOError()])

    But I agree that mutating an argument which is only used to create an immutable tuple shouldn't change the repr.

    Reacted by Ganden Schaffner
  4. serhiy-storchaka commented on Nov 19, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on Nov 19, 2025
    Member
    More actions

    This may be a part of more complex problem. See #137889.

    Reacted by dr-carlos and Ganden Schaffner
  5. StanFromIreland
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Nov 19, 2025
  6. iritkatriel
    added a commit that references this issue on Dec 7, 2025

    gh-141732: Fix `ExceptionGroup` repr changing when original exception…

    ff2577f
  7. miss-islington
    added a commit that references this issue on Dec 7, 2025

    pythongh-141732: Fix `ExceptionGroup` repr changing when original exc…

    30667ed
  8. iritkatriel
    added a commit that references this issue on Dec 8, 2025

    [3.13] gh-141732: Fix ExceptionGroup repr changing when original exce…

    d768900
  9. hugovk commented on Feb 3, 2026

    @hugovk
    hugovk
    on Feb 3, 2026
    Member
    More actions

    This has been merged in main and 3.13 but cannot be merged for 3.14 because of failing CI: #142388.

    Please can you check the backport?

  10. dr-carlos commented on Feb 3, 2026

    @dr-carlos
    dr-carlos
    on Feb 3, 2026
    Contributor
    More actions

    This has been merged in main and 3.13 but cannot be merged for 3.14 because of failing CI: #142388.

    Please can you check the backport?

    Yes, will do!
    Opened #144445

  11. thunze
    added 3 commits that reference this issue on Feb 7, 2026

    python3Packages.exceptiongroup: fix build on staging

    ea6a5d3

    python3Packages.exceptiongroup: fix build on staging

    60588ad

    python3Packages.exceptiongroup: fix build on staging

    ede0572
  12. mweinelt
    added a commit that references this issue on Feb 8, 2026

    python3Packages.exceptiongroup: fix build after cpython repr changes

    294b175
  13. nixpkgs-ci
    added a commit that references this issue on Feb 14, 2026

    python3Packages.exceptiongroup: fix build after cpython repr changes

    2e5254c
  14. mdaniels5757
    added a commit that references this issue on Feb 25, 2026

    python3Packages.exceptiongroup: fix build after cpython repr changes

    84d06fd
  15. ambv
    added a commit that references this issue on Mar 23, 2026

    [3.14] gh-141732: Fix ExceptionGroup repr changing when original exce…

    dd4ea46
  16. ambv
    closed this as completedon Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.