cpython: 7caab48f171e (original) (raw)
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -409,7 +409,7 @@ ABC hierarchy::
When writing to the path fails because the path is read-only
(:attr:errno.EACCES
), do not propagate the exception.
Create a code object from Python source.
--- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -931,7 +931,7 @@ class SourceLoader(_LoaderBasics): raise ImportError("Failed to decode source file", name=fullname) from exc
The 'data' argument can be any object type that compile() supports. @@ -984,7 +984,7 @@ class SourceLoader(_LoaderBasics): raise ImportError(msg.format(bytecode_path), name=fullname, path=bytecode_path) source_bytes = self.get_data(source_path)
code_object = self.compile_source(source_bytes, source_path)[](#l2.16)
code_object = self.source_to_code(source_bytes, source_path)[](#l2.17) _verbose_message('code object from {}', source_path)[](#l2.18) if (not sys.dont_write_bytecode and bytecode_path is not None and[](#l2.19) source_mtime is not None):[](#l2.20)
--- a/Lib/test/test_importlib/source/test_abc_loader.py +++ b/Lib/test/test_importlib/source/test_abc_loader.py @@ -148,9 +148,9 @@ class SourceOnlyLoaderTests(SourceLoader code_object = self.loader.get_code(self.name) self.verify_code(code_object)
code = self.loader.compile_source(self.loader.source, self.path)[](#l3.10)
code = self.loader.source_to_code(self.loader.source, self.path)[](#l3.11) self.verify_code(code)[](#l3.12)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -190,7 +190,7 @@ Library
- Issue #16522: added FAIL_FAST flag to doctest. -- Issue #15627: Add the importlib.abc.SourceLoader.compile_source() method. +- Issue #15627: Add the importlib.abc.SourceLoader.source_to_code() method.
- Issue #16408: Fix file descriptors not being closed in error conditions in the zipfile module. Patch by Serhiy Storchaka.
--- a/Python/importlib.h +++ b/Python/importlib.h @@ -2200,11 +2200,11 @@ unsigned char _Py_M__importlib[] = { 97,116,97,117,4,0,0,0,112,97,116,104,40,0,0,0, 0,40,0,0,0,0,117,29,0,0,0,60,102,114,111,122, 101,110,32,105,109,112,111,114,116,108,105,98,46,95,98,111,
- 111,116,115,116,114,97,112,62,117,14,0,0,0,99,111,109,
- 112,105,108,101,95,115,111,117,114,99,101,166,3,0,0,115,
- 111,116,115,116,114,97,112,62,117,14,0,0,0,115,111,117,
- 114,99,101,95,116,111,95,99,111,100,101,166,3,0,0,115, 4,0,0,0,0,5,18,1,117,27,0,0,0,83,111,117,
- 114,99,101,76,111,97,100,101,114,46,99,111,109,112,105,108,
- 101,95,115,111,117,114,99,101,99,2,0,0,0,0,0,0,
- 114,99,101,76,111,97,100,101,114,46,115,111,117,114,99,101,
- 95,116,111,95,99,111,100,101,99,2,0,0,0,0,0,0, 0,12,0,0,0,45,0,0,0,67,0,0,0,115,43,2, 0,0,124,0,0,106,0,0,124,1,0,131,1,0,125,2, 0,100,8,0,125,3,0,121,16,0,116,2,0,124,2,0, @@ -2278,8 +2278,8 @@ unsigned char _Py_M__importlib[] = { 99,101,117,10,0,0,0,95,99,111,100,101,95,116,121,112, 101,117,4,0,0,0,95,105,109,112,117,16,0,0,0,95, 102,105,120,95,99,111,95,102,105,108,101,110,97,109,101,117,
- 6,0,0,0,102,111,114,109,97,116,117,14,0,0,0,99,
- 111,109,112,105,108,101,95,115,111,117,114,99,101,117,3,0,
- 6,0,0,0,102,111,114,109,97,116,117,14,0,0,0,115,
- 111,117,114,99,101,95,116,111,95,99,111,100,101,117,3,0, 0,0,115,121,115,117,19,0,0,0,100,111,110,116,95,119, 114,105,116,101,95,98,121,116,101,99,111,100,101,117,9,0, 0,0,98,121,116,101,97,114,114,97,121,117,12,0,0,0, @@ -2345,8 +2345,8 @@ unsigned char _Py_M__importlib[] = { 112,97,116,104,95,115,116,97,116,115,117,15,0,0,0,95, 99,97,99,104,101,95,98,121,116,101,99,111,100,101,117,8, 0,0,0,115,101,116,95,100,97,116,97,117,10,0,0,0,