gh-140228: Avoid making unnecessary syscalls in linecache for frozen modules (#140377)

This commit is contained in:
tconley1428 2025-10-28 23:06:22 -07:00 committed by GitHub
parent ce4b0ede16
commit c41f84ff61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -123,9 +123,12 @@ def updatecache(filename, module_globals=None):
if _source_unavailable(filename):
return []
if filename.startswith('<frozen ') and module_globals is not None:
if filename.startswith('<frozen '):
# This is a frozen module, so we need to use the filename
# from the module globals.
if module_globals is None:
return []
fullname = module_globals.get('__file__')
if fullname is None:
return []