wrong error message when inspect getfile a custom module
Open
Nobody has claimed this yet.
stdlib
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the custom-module example and inspect Lib/inspect.py around line 822, where the incorrect message is raised. Verify the resulting error wording distinguishes a custom module from a built-in module; linked PRs gh-138543 and gh-143769 show that work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100