Skip to content

importlib.util._find_spec_from_path('__main__') fails #117742

Open
@terryjreedy

Description

@terryjreedy

Bug report

Module pyclbr cannot browse a file named __main__ because it cannot get the spec.

>>> from importlib import util
>>> util._find_spec_from_path('__init__')
ModuleSpec(name='__init__', loader=<_frozen_importlib_external.SourceFileLoader object at 0x000001C6C2462DB0>, origin='C:\\Programs\\Python313\\Lib\\idlelib\\__init__.py')
>>> util._find_spec_from_path('__main__')
Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    util._find_spec_from_path('__main__')
  File "<frozen importlib.util>", line 67, in _find_spec_from_path
ValueError: __main__.__spec__ is None

This is 3.13.0a5 but same in prior versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-importlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions