wrong error message when inspect getfile a custom module
未关闭
还没有人认领这个 Issue。
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- 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