Skip to content

colors are missing on (Base)ExceptionGroup tracebacks in the pyrepl #125593

Closed

Description

@graingert

Bug description:

import sys

class InvalidFruitException(Exception):
    pass


def eat_fruit(fruit):
    if fruit == "banana":
        raise InvalidFruitException("no herbs please, only fruit")
    if fruit == "rock":
        raise InvalidFruitException("too tough")


def demo_continue_loop():
    food = ["apple", "rock", "orange", "banana"]
    exceptions = []
    try:
        for i, f in enumerate(food):
            try:
                eat_fruit(f)
            except Exception as e:
                e.add_note(f"failed on loop {i=} {f=}")
                exceptions.append(e)
        if exceptions:
            raise ExceptionGroup("multiple errors eating food", exceptions)
    finally:
        del exceptions  # no refcycles please!

def main():
    demo_continue_loop()
    return 0

if __name__ == "__main__":
    sys.exit(main())

here's the output:
https://asciinema.org/a/681263
681263

I'd expect the eat_fruit() parts to be highlighted in red

CPython versions tested on:

3.13, 3.14

Operating systems tested on:

Linux, macOS

This was added in #112730 but it looks like ExceptionGroups were missed

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.13only security fixes
    3.14bugs and security fixes
    on Oct 16, 2024
  2. changed the title [-]colors are missing on ExceptionGroup tracebacks[/-] [+]colors are missing on ExceptionGroup tracebacks in the pyrepl[/+] on Oct 16, 2024
  3. Eclips4 commented on Oct 16, 2024

    @Eclips4
    Member

    @graingert are you working on this issue? If not, @wrongnull would like to take this one :)

  4. graingert commented on Oct 16, 2024

    @graingert
    ContributorAuthor

    @Eclips4 no I've not looked into it yet

  5. changed the title [-]colors are missing on ExceptionGroup tracebacks in the pyrepl[/-] [+]colors are missing on (Base)ExceptionGroup tracebacks in the pyrepl[/+] on Oct 16, 2024
  6. graingert commented on Oct 16, 2024

    @graingert
    ContributorAuthor

    one minor request I have is that exception notes have a color distinct to exception messages

  7. wrongnull commented on Oct 16, 2024

    @wrongnull
    Contributor

    I'm working on this and found a fix. The pull request will be sent tomorrow

  8. added a commit that references this issue on Oct 27, 2024
  9. added a commit that references this issue on Oct 27, 2024
  10. added a commit that references this issue on Oct 27, 2024
  11. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.13only security fixes3.14bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions