]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-102700: allow built-in modules to be submodules (GH-103162)
authorBrett Cannon <brett@python.org>
Thu, 6 Apr 2023 21:19:54 +0000 (14:19 -0700)
committerGitHub <noreply@github.com>
Thu, 6 Apr 2023 21:19:54 +0000 (14:19 -0700)
Lib/importlib/_bootstrap.py
Lib/test/test_importlib/builtin/test_finder.py
Misc/NEWS.d/next/Core and Builtins/2023-04-01-00-46-31.gh-issue-102700.493NB4.rst [new file with mode: 0644]

index bebe7e15cbce6742c76a2bcee6dc40886bbc9564..22fa2469964ab3e3fe29b1eee7257ae4135d66a7 100644 (file)
@@ -887,8 +887,6 @@ class BuiltinImporter:
 
     @classmethod
     def find_spec(cls, fullname, path=None, target=None):
-        if path is not None:
-            return None
         if _imp.is_builtin(fullname):
             return spec_from_loader(fullname, cls, origin=cls._ORIGIN)
         else:
index a4869e07b9c0c2afca0fdb8a99700478a3c74f45..81dc5a3699d952514f6045029f18cb81a28d4468 100644 (file)
@@ -37,13 +37,6 @@ class FindSpecTests(abc.FinderTests):
         spec = self.machinery.BuiltinImporter.find_spec(name)
         self.assertIsNone(spec)
 
-    def test_ignore_path(self):
-        # The value for 'path' should always trigger a failed import.
-        with util.uncache(util.BUILTINS.good_name):
-            spec = self.machinery.BuiltinImporter.find_spec(util.BUILTINS.good_name,
-                                                            ['pkg'])
-            self.assertIsNone(spec)
-
 
 (Frozen_FindSpecTests,
  Source_FindSpecTests
@@ -77,16 +70,6 @@ class FinderTests(abc.FinderTests):
             loader = self.machinery.BuiltinImporter.find_module('importlib')
         self.assertIsNone(loader)
 
-    def test_ignore_path(self):
-        # The value for 'path' should always trigger a failed import.
-        with util.uncache(util.BUILTINS.good_name):
-            with warnings.catch_warnings():
-                warnings.simplefilter("ignore", DeprecationWarning)
-                loader = self.machinery.BuiltinImporter.find_module(
-                                                        util.BUILTINS.good_name,
-                                                        ['pkg'])
-            self.assertIsNone(loader)
-
 
 (Frozen_FinderTests,
  Source_FinderTests
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-01-00-46-31.gh-issue-102700.493NB4.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-01-00-46-31.gh-issue-102700.493NB4.rst
new file mode 100644 (file)
index 0000000..4695148
--- /dev/null
@@ -0,0 +1 @@
+Allow built-in modules to be submodules. This allows submodules to be statically linked into a CPython binary.