mirror of
https://github.com/python/cpython.git
synced 2025-10-15 03:10:29 +00:00
GH-102700: allow built-in modules to be submodules (GH-103162)
This commit is contained in:
parent
dca7d174f1
commit
5d08c3ff7d
3 changed files with 1 additions and 19 deletions
|
@ -887,8 +887,6 @@ class BuiltinImporter:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def find_spec(cls, fullname, path=None, target=None):
|
def find_spec(cls, fullname, path=None, target=None):
|
||||||
if path is not None:
|
|
||||||
return None
|
|
||||||
if _imp.is_builtin(fullname):
|
if _imp.is_builtin(fullname):
|
||||||
return spec_from_loader(fullname, cls, origin=cls._ORIGIN)
|
return spec_from_loader(fullname, cls, origin=cls._ORIGIN)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -37,13 +37,6 @@ class FindSpecTests(abc.FinderTests):
|
||||||
spec = self.machinery.BuiltinImporter.find_spec(name)
|
spec = self.machinery.BuiltinImporter.find_spec(name)
|
||||||
self.assertIsNone(spec)
|
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,
|
(Frozen_FindSpecTests,
|
||||||
Source_FindSpecTests
|
Source_FindSpecTests
|
||||||
|
@ -77,16 +70,6 @@ class FinderTests(abc.FinderTests):
|
||||||
loader = self.machinery.BuiltinImporter.find_module('importlib')
|
loader = self.machinery.BuiltinImporter.find_module('importlib')
|
||||||
self.assertIsNone(loader)
|
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,
|
(Frozen_FinderTests,
|
||||||
Source_FinderTests
|
Source_FinderTests
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Allow built-in modules to be submodules. This allows submodules to be statically linked into a CPython binary.
|
Loading…
Add table
Add a link
Reference in a new issue