Skip to content

[3.15] gh-157146: Let linecache read sources from zip archives on sys.path (GH-157147) - #157269

Merged
gpshead merged 1 commit into
python:3.15from
miss-islington:backport-1d6e7d5-3.15
Oct 10, 2026
Merged

gpshead merged 1 commit into
python:3.15from
miss-islington:backport-1d6e7d5-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

linecache.getline() now works for a .zip archive on sys.path without the caller having to pass module_globals. Callers that only have a file name, such as pdb, warnings, and doctest, now get source. Reads of such files go through the get_data() method of the path entry finder registered for the archive in sys.path_importer_cache.

Prior to this: os.stat() would fail on the archive-internal path, the loader lookup needed the globals, and the sys.path search would only handle relative names and assumed a filesystem rather than using an importer.
(cherry picked from commit 1d6e7d5)

Co-authored-by: Gregory P. Smith 68491+gpshead@users.noreply.github.com

…path (pythonGH-157147)

linecache.getline() now works for a .zip archive on sys.path without the caller having to pass module_globals. Callers that only have a file name, such as pdb, warnings, and doctest, now get source. Reads of such files go through the get_data() method of the path entry finder registered for the archive in sys.path_importer_cache.

Prior to this: os.stat() would fail on the archive-internal path, the loader lookup needed the globals, and the sys.path search would only handle relative names and assumed a filesystem rather than using an importer.
(cherry picked from commit 1d6e7d5)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
@gpshead

gpshead commented Sep 10, 2026

Copy link
Copy Markdown
Member

targeting 3.15.1

@gpshead gpshead self-assigned this Sep 10, 2026
@gpshead
gpshead marked this pull request as ready for review October 10, 2026 21:31
@gpshead
gpshead merged commit e2d1055 into python:3.15 Oct 10, 2026
60 checks passed
@miss-islington
miss-islington deleted the backport-1d6e7d5-3.15 branch October 10, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants