python / python/cpython

`NameError` has different actions when be raised in IDLE

未關閉
#135,511 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

topic-IDLE type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

In IDLE, I raised three different exceptions. The output is:

>>>raise Exception("123\n456")
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    raise Exception("123\n456")
Exception: 123
456
>>>raise NameError("123\n456")
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    raise NameError("123\n456")
456
>>>raise OSError("123\n456")
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    raise OSError("123\n456")
OSError: 123
456

Only NameError cannot show the Exception Type if the text has two or more lines.
In shell the action is same with other exception.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs
  • gh-135526

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先在 Python 3.13 的 IDLE shell 中重現這三個例外情況,並將其與一般 shell 的輸出進行比較。追蹤 IDLE 如何格式化多行例外訊息,接著確認多行 NameError 顯示的例外類型是否與 Exception 和 OSError 一致;連結的 PR gh-135526 顯示相關工作已經在進行中。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
desktop
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。