Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows)

This commit is contained in:
Brett Cannon 2013-11-22 11:58:17 -05:00
parent 29eac42f49
commit fddc311fe8
2 changed files with 200 additions and 194 deletions

View file

@ -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()