cpython: a72a0e4dad20 (original) (raw)

--- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1559,6 +1559,13 @@ class FileLoader: self.name = fullname self.path = path

+

+ @_check_name def load_module(self, fullname): """Load a module from a file.""" @@ -1653,6 +1660,13 @@ class ExtensionFileLoader: self.name = name self.path = path

+

+ @_check_name def load_module(self, fullname): """Load an extension module."""

--- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -28,6 +28,15 @@ class LoaderTests(abc.LoaderTests): with self.assertRaises(ImportError): self.load_module('XXX')

+

def test_module(self): with util.uncache(ext_util.NAME):

--- a/Lib/test/test_importlib/source/test_file_loader.py +++ b/Lib/test/test_importlib/source/test_file_loader.py @@ -27,6 +27,11 @@ class SimpleTest(abc.LoaderTests): """

+ def test_load_module_API(self): class Tester(self.abc.FileLoader): def get_source(self, _): return 'attr = 42' @@ -53,6 +58,14 @@ class SimpleTest(abc.LoaderTests): with self.assertRaises(ImportError): loader.get_filename(name + 'XXX')

+

+ # [basic] def test_module(self): with source_util.create_modules('_temp') as mapping:

--- a/Lib/test/test_importlib/test_api.py +++ b/Lib/test/test_importlib/test_api.py @@ -288,8 +288,7 @@ class FindSpecTests: self.assertNotIn(name, sorted(sys.modules)) # Ensure successive calls behave the same. spec_again = self.init.find_spec(fullname, [pkg_dir])

def test_find_submodule_missing_path(self): name = 'spam'

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -203,6 +203,8 @@ Library no exception detail exists (no colon following the exception's name, or a colon does follow but no text follows the colon). +- Issue #19927: Add eq to path-based loaders in importlib. +

--- a/Python/importlib.h +++ b/Python/importlib.h @@ -1477,7 +1477,7 @@ const unsigned char _Py_M__importlib[] = 67,0,0,0,114,169,0,0,0,114,217,0,0,0,218,6, 99,97,99,104,101,100,218,12,104,97,115,95,108,111,99,97, 116,105,111,110,114,209,0,0,0,41,3,114,71,0,0,0,