]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-145506: Fixes CVE-2026-2297 by ensuring SourcelessFileLoader uses io.open_code...
authorSteve Dower <steve.dower@python.org>
Wed, 4 Mar 2026 19:55:52 +0000 (19:55 +0000)
committerGitHub <noreply@github.com>
Wed, 4 Mar 2026 19:55:52 +0000 (19:55 +0000)
Lib/importlib/_bootstrap_external.py
Misc/NEWS.d/next/Security/2026-03-04-18-59-17.gh-issue-145506.6hwvEh.rst [new file with mode: 0644]

index 213190d2098e7568fc4d34bba5b90018f631a86d..a1cb729efb7fef214ffdca0a7dd2d7b6cfc0fcdf 100644 (file)
@@ -918,7 +918,7 @@ class FileLoader:
 
     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:
diff --git a/Misc/NEWS.d/next/Security/2026-03-04-18-59-17.gh-issue-145506.6hwvEh.rst b/Misc/NEWS.d/next/Security/2026-03-04-18-59-17.gh-issue-145506.6hwvEh.rst
new file mode 100644 (file)
index 0000000..dcdb44d
--- /dev/null
@@ -0,0 +1,2 @@
+Fixes :cve:`2026-2297` by ensuring that ``SourcelessFileLoader`` uses
+:func:`io.open_code` when opening ``.pyc`` files.