mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows)
This commit is contained in:
parent
29eac42f49
commit
fddc311fe8
2 changed files with 200 additions and 194 deletions
|
@ -2268,6 +2268,8 @@ def __import__(name, globals=None, locals=None, fromlist=(), level=0):
|
|||
|
||||
def _builtin_from_name(name):
|
||||
spec = BuiltinImporter.find_spec(name)
|
||||
if spec is None:
|
||||
raise ImportError('no built-in module named ' + name)
|
||||
methods = _SpecMethods(spec)
|
||||
return methods._load_unlocked()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue