Skip to content

Commit f2f8c86

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

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
@@ -1126,7 +1126,7 @@ def get_filename(self, fullname):
11261126

11271127
def get_data(self, path):
11281128
"""Return the data from path as raw bytes."""
1129-
if isinstance(self, (SourceLoader, ExtensionFileLoader)):
1129+
if isinstance(self, (SourceLoader, SourcelessFileLoader, ExtensionFileLoader)):
11301130
with _io.open_code(str(path)) as file:
11311131
return file.read()
11321132
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)