gh-140228: Avoid making unnecessary syscalls in linecache for frozen modules (GH-140377)
(cherry picked from commit
c41f84ff61c52e3ff7ef86b0c66208b29613d23d)
Co-authored-by: tconley1428 <tconley1428@gmail.com>
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 []
--- /dev/null
+Avoid making unnecessary filesystem calls for frozen modules in :mod:`linecache` when the global module cache is not present.