[3.14] gh-140228: Avoid making unnecessary syscalls in linecache for frozen modules (GH-140377) (#140738)

gh-140228: Avoid making unnecessary syscalls in linecache for frozen modules (GH-140377)
(cherry picked from commit c41f84ff61)

Co-authored-by: tconley1428 <tconley1428@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-10-29 17:26:38 +01:00 committed by GitHub
parent c45ab05a3a
commit 6d0e1c8478
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -131,9 +131,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 []