https://github.com/python/cpython/commit/6d0e1c8478cbf3d16f7dd9ef3c947de8c9a46a11 commit: 6d0e1c8478cbf3d16f7dd9ef3c947de8c9a46a11 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: gaogaotiantian <[email protected]> date: 2025-10-29T09:26:38-07:00 summary:
[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 c41f84ff61c52e3ff7ef86b0c66208b29613d23d) Co-authored-by: tconley1428 <[email protected]> files: A Misc/NEWS.d/next/Library/2025-10-28-17-43-51.gh-issue-140228.8kfHhO.rst M Lib/linecache.py diff --git a/Lib/linecache.py b/Lib/linecache.py index 87d7d6fda657e4..2b5a31b3e75bc1 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -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 [] diff --git a/Misc/NEWS.d/next/Library/2025-10-28-17-43-51.gh-issue-140228.8kfHhO.rst b/Misc/NEWS.d/next/Library/2025-10-28-17-43-51.gh-issue-140228.8kfHhO.rst new file mode 100644 index 00000000000000..b3b692bae62c5d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-10-28-17-43-51.gh-issue-140228.8kfHhO.rst @@ -0,0 +1 @@ +Avoid making unnecessary filesystem calls for frozen modules in :mod:`linecache` when the global module cache is not present. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
