Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix the case of the __main__ module.
  • Loading branch information
serhiy-storchaka committed Nov 9, 2025
commit dc98bc6cb50cafcfbaa718dcf15907e7bf4e82a3
6 changes: 5 additions & 1 deletion Lib/linecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,12 @@ def _bless_my_loader(module_globals):
loader = module_globals.get('__loader__')
if loader is None and '__spec__' not in module_globals:
return None

spec = module_globals.get('__spec__')

# The __main__ module has __spec__ = None.
if spec is None and module_globals.get('__name__') == '__main__':
return loader

spec_loader = getattr(spec, 'loader', None)
if spec_loader is None:
import warnings
Expand Down
Loading