[Python-checkins] cpython (merge 3.2 -> default): Merge 3.2: Fix the import machinery if there is an error on sys.path or
victor.stinner
python-checkins at python.org
Thu Sep 15 19:47:07 CEST 2011
http://hg.python.org/cpython/rev/3ff9a2d5f5e5
changeset: 72386:3ff9a2d5f5e5
parent: 72384:c6d52971dd2a
parent: 72385:4247f5e221c6
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Thu Sep 15 19:38:54 2011 +0200
summary:
Merge 3.2: Fix the import machinery if there is an error on sys.path or sys.meta_path
find_module() now raises a RuntimeError, instead of ImportError, on an error on
sys.path or sys.meta_path because load_package() and import_submodule() returns
None and clear the exception if a ImportError occurred.
files:
Python/import.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -1992,7 +1992,7 @@
meta_path = PySys_GetObject("meta_path");
if (meta_path == NULL || !PyList_Check(meta_path)) {
- PyErr_SetString(PyExc_ImportError,
+ PyErr_SetString(PyExc_RuntimeError,
"sys.meta_path must be a list of "
"import hooks");
return NULL;
@@ -2044,14 +2044,14 @@
}
if (search_path_list == NULL || !PyList_Check(search_path_list)) {
- PyErr_SetString(PyExc_ImportError,
+ PyErr_SetString(PyExc_RuntimeError,
"sys.path must be a list of directory names");
return NULL;
}
path_hooks = PySys_GetObject("path_hooks");
if (path_hooks == NULL || !PyList_Check(path_hooks)) {
- PyErr_SetString(PyExc_ImportError,
+ PyErr_SetString(PyExc_RuntimeError,
"sys.path_hooks must be a list of "
"import hooks");
return NULL;
@@ -2059,7 +2059,7 @@
path_importer_cache = PySys_GetObject("path_importer_cache");
if (path_importer_cache == NULL ||
!PyDict_Check(path_importer_cache)) {
- PyErr_SetString(PyExc_ImportError,
+ PyErr_SetString(PyExc_RuntimeError,
"sys.path_importer_cache must be a dict");
return NULL;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list