Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better str() for BaseExceptionGroup #90885

Closed
iritkatriel opened this issue Feb 12, 2022 · 3 comments
Closed

Better str() for BaseExceptionGroup #90885

iritkatriel opened this issue Feb 12, 2022 · 3 comments
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@iritkatriel
Copy link
Member

BPO 46729
Nosy @gvanrossum, @1st1, @iritkatriel
PRs
  • bpo-46729: improved str() for BaseExceptionGroup #31294
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-02-22.18:30:58.471>
    created_at = <Date 2022-02-12.11:02:01.480>
    labels = ['interpreter-core', '3.11']
    title = 'Better str() for BaseExceptionGroup'
    updated_at = <Date 2022-02-22.18:30:58.469>
    user = 'https://github.com/iritkatriel'

    bugs.python.org fields:

    activity = <Date 2022-02-22.18:30:58.469>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-22.18:30:58.471>
    closer = 'iritkatriel'
    components = ['Interpreter Core']
    creation = <Date 2022-02-12.11:02:01.480>
    creator = 'iritkatriel'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46729
    keywords = ['patch', '3.2regression']
    message_count = 3.0
    messages = ['413121', '413138', '413735']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'yselivanov', 'iritkatriel']
    pr_nums = ['31294']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue46729'
    versions = ['Python 3.11']

    @iritkatriel
    Copy link
    Member Author

    The str() of exception groups currently contains just the msg as passed to the constructor. This turned out to be confusing (see #31270 (comment)).

    We should consider whether it is possible to design a more informative str().

    Note that the str() is included in the standard traceback, which include the line:

    f"{type(e)}: {str(e)}"

    So str() should not repeat the type, and should not clutter this too much. Probably just the msg plus the number of contained leaf exceptions.

    PEP-654 needs to be updated with what we do here, and the change needs to be approved by the SC.

    @iritkatriel iritkatriel added 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Feb 12, 2022
    @gvanrossum
    Copy link
    Member

    Should it show the number of immediate subexceptions (i.e., len(eg.exceptions)) or the number of leaf exceptions? I'd be happy with the former (since that's what EdgeDb's MultiError does), which would not require adding an extra field to the base exception group struct.

    @iritkatriel
    Copy link
    Member Author

    New changeset 38b5acf by Irit Katriel in branch 'main':
    bpo-46729: add number of sub-exceptions in str() of BaseExceptionGroup (GH-31294)
    38b5acf

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants