Skip to content

Commit 73f91c3

Browse files
committed
gh-145506: Fixes CVE-2026-2297 by ensuring SourcelessFileLoader uses io.open_code
1 parent 8a7eb8b commit 73f91c3

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

919919
def get_data(self, path):
920920
"""Return the data from path as raw bytes."""
921-
if isinstance(self, (SourceLoader, ExtensionFileLoader)):
921+
if isinstance(self, (SourceLoader, SourcelessFileLoader, ExtensionFileLoader)):
922922
with _io.open_code(str(path)) as file:
923923
return file.read()
924924
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)