← 输入框|github.com|刷新
Skip to content

Better str() for BaseExceptionGroup #90885

Closed

Description

@iritkatriel
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']

    Activity

    1. iritkatriel commented on Feb 12, 2022

      @iritkatriel
      MemberAuthor

      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.

    2. gvanrossum commented on Feb 12, 2022

      @gvanrossum
      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.

    3. iritkatriel commented on Feb 22, 2022

      @iritkatriel
      MemberAuthor

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

    4. transferred this issue fromon Apr 10, 2022
    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

      3.11only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions