ipython / ipython/ipykernel

`ExceptionGroup` doesn't show sub-exceptions

Đang mở
#1,149 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
734
Fork
412
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
8

Mô tả

As seen below, Python 3.11 `ExceptionGroup` objects don't show sub-exceptions when displayed; explicitly catching and using `traceback.print_exc()` is required to see them:
```
❯ jupyter console

In [1]: exc = ExceptionGroup("derp", [Exception("herp")])

In [2]: raise exc
---------------------------------------------------------------------------
ExceptionGroup Traceback (most recent call last)
Cell In[2], line 1
----> 1 raise exc

ExceptionGroup: derp (1 sub-exception)

In [3]: try:
...: raise exc
...: except:
...: import traceback; traceback.print_exc()
...:
+ Exception Group Traceback (most recent call last):
| File "C:\Users\evanj\AppData\Local\Temp\ipykernel_20028\3102285775.py", line 2, in
| raise exc
| File "C:\Users\evanj\anaconda3\Lib\site-packages\IPython\core\interactiveshell.py", line 3505, in run_code
| exec(code_obj, self.user_global_ns, self.user_ns)
| File "C:\Users\evanj\AppData\Local\Temp\ipykernel_20028\3429297078.py", line 1, in
| raise exc
| ExceptionGroup: derp (1 sub-exception)
+-+---------------- 1 ----------------
| Exception: herp
+------------------------------------
```

Versions:
```
Python 3.11.4
ipykernel 6.19.2
ipython 8.12.0
jupyter 1.0.0
jupyter_client 7.4.9
jupyter-console 6.6.3
jupyter_core 5.3.0
jupyter-events 0.6.3
jupyter-server 1.23.4
jupyter_server_fileid 0.9.0
jupyter_server_ydoc 0.8.0
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start by reproducing the Python 3.11 ExceptionGroup example in a Jupyter console and compare normal display with traceback.print_exc(). Trace the kernel's exception-display path; done means raising an ExceptionGroup in the console shows its nested exceptions without explicitly calling traceback.print_exc().

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.