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

gh-157146: Let linecache read sources from zip archives on sys.path (GH-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 1d6e7d5987e86ef58703ea698c5a04f0bd249e21)

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