[3.13] gh-145506: Fixes CVE-2026-2297 by ensuring SourcelessFileLoader uses io.open_code (GH-145507)

(cherry picked from commit a51b1b512d)

Co-authored-by: Steve Dower <steve.dower@python.org>
This commit is contained in:
Miss Islington (bot) 2026-03-04 21:17:04 +01:00 committed by GitHub
parent fb83592b56
commit 482d6f8bdb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -1210,7 +1210,7 @@ def get_filename(self, fullname):
def get_data(self, path):
"""Return the data from path as raw bytes."""
if isinstance(self, (SourceLoader, ExtensionFileLoader)):
if isinstance(self, (SourceLoader, SourcelessFileLoader, ExtensionFileLoader)):
with _io.open_code(str(path)) as file:
return file.read()
else:

View file

@ -0,0 +1,2 @@
Fixes :cve:`2026-2297` by ensuring that ``SourcelessFileLoader`` uses
:func:`io.open_code` when opening ``.pyc`` files.