[Python-checkins] cpython: Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows)

brett.cannon python-checkins at python.org
Fri Nov 22 17:58:21 CET 2013


http://hg.python.org/cpython/rev/2bea86df60b9
changeset:   87351:2bea86df60b9
user:        Brett Cannon <brett at python.org>
date:        Fri Nov 22 11:58:17 2013 -0500
summary:
  Don't assume trying to find a builtin will succeed (e.g. posix isn't on Windows)

files:
  Lib/importlib/_bootstrap.py |    2 +
  Python/importlib.h          |  392 ++++++++++++-----------
  2 files changed, 200 insertions(+), 194 deletions(-)


diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -2268,6 +2268,8 @@
 
 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()
 
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list