Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

wrong error message when inspect getfile a custom module #138542

Open
Labels
stdlibStandard Library Python modules in the Lib/ directory type-bugAn unexpected behavior, bug, or error
@yihong0618

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directory type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /