wrong error message when inspect getfile a custom module
未關閉
還沒有人認領這個 Issue。
stdlib
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
>>> import inspect
>>> import types
... custom_module = types.ModuleType('my_custom_module')
...
>>> inspect.getfile(custom_module)
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
inspect.getfile(custom_module)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/Users/yihong/repos/cpython/Lib/inspect.py", line 822, in getfile
raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module 'my_custom_module'> is a built-in module
as the code it is a costom module but not a build-in module
the error message is wrong
CPython versions tested on:
CPython main branch
Operating systems tested on:
Other
Linked PRs
- gh-138543
- gh-143769
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
重現自訂模組範例,並檢查 Lib/inspect.py 第 822 行附近觸發錯誤訊息的位置。確認產生的錯誤文字能區分自訂模組和內建模組;關聯的 PR gh-138543 和 gh-143769 表明這項工作已經在進行中。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100