Skip to content

Commit 8a03a63

Browse files
zoobamiss-islington
authored andcommitted
gh-145506: Fixes CVE-2026-2297 by ensuring SourcelessFileLoader uses io.open_code (GH-145507)
(cherry picked from commit a51b1b5) Co-authored-by: Steve Dower <steve.dower@python.org>
1 parent 27c6454 commit 8a03a63

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Lib/importlib/_bootstrap_external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ def get_filename(self, fullname):
10691069

10701070
def get_data(self, path):
10711071
"""Return the data from path as raw bytes."""
1072-
if isinstance(self, (SourceLoader, ExtensionFileLoader)):
1072+
if isinstance(self, (SourceLoader, SourcelessFileLoader, ExtensionFileLoader)):
10731073
with _io.open_code(str(path)) as file:
10741074
return file.read()
10751075
else:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixes :cve:`2026-2297` by ensuring that ``SourcelessFileLoader`` uses
2+
:func:`io.open_code` when opening ``.pyc`` files.

0 commit comments

Comments
 (0)