Skip to content

Commit 6d0e1c8

Browse files
[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 c41f84f) Co-authored-by: tconley1428 <[email protected]>
1 parent c45ab05 commit 6d0e1c8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/linecache.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ def updatecache(filename, module_globals=None):
131131
if _source_unavailable(filename):
132132
return []
133133

134-
if filename.startswith('<frozen ') and module_globals is not None:
134+
if filename.startswith('<frozen '):
135135
# This is a frozen module, so we need to use the filename
136136
# from the module globals.
137+
if module_globals is None:
138+
return []
139+
137140
fullname = module_globals.get('__file__')
138141
if fullname is None:
139142
return []
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid making unnecessary filesystem calls for frozen modules in :mod:`linecache` when the global module cache is not present.

0 commit comments

Comments
 (0)