This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: Better str() for BaseExceptionGroup
类型: Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: 抄送列表: gvanrossum, iritkatriel, yselivanov
优先级: normal 关键字: 3.2regression, patch

Created on 2022-02-12 11:02 by iritkatriel, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31294 merged iritkatriel, 2022-02-12 11:03
Messages (3)
msg413121 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) 日期: 2022-02-12 11:02
The str() of exception groups currently contains just the msg as passed to the constructor. This turned out to be confusing (see https://github.com/python/cpython/pull/31270#issuecomment-1036418346).

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.
msg413138 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) 日期: 2022-02-12 17:52
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.
msg413735 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) 日期: 2022-02-22 18:29
New changeset 38b5acf8673ce42a401263a2528202e44d6ae60a by Irit Katriel in branch 'main':
bpo-46729: add number of sub-exceptions in str() of BaseExceptionGroup (GH-31294)
https://github.com/python/cpython/commit/38b5acf8673ce42a401263a2528202e44d6ae60a
历史
日期 用户 动作 参数
2022-04-11 14:59:56admin修改github: 90885
2022-02-22 18:30:58iritkatriel修改状态: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-02-22 18:29:02iritkatriel修改消息: + msg413735
2022-02-12 17:52:50gvanrossum修改抄送: + gvanrossum, yselivanov
消息: + msg413138
2022-02-12 11:03:13iritkatriel修改keywords: + patch
stage: patch review
pull_requests: + pull_request29453
2022-02-12 11:02:01iritkatriel创建