summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-15 17:45:53 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-15 17:45:53 (GMT)
commited36c06f1dbc8888d94491d3c2e83aa296e9b33a (patch)
tree7566a528fcc1b10c04bfb2a184826695510aff58 /Python
parent503e5e12c27bf130d388e09fe770d16d9b486821 (diff)
downloadcpython-ed36c06f1dbc8888d94491d3c2e83aa296e9b33a.zip
cpython-ed36c06f1dbc8888d94491d3c2e83aa296e9b33a.tar.gz
cpython-ed36c06f1dbc8888d94491d3c2e83aa296e9b33a.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c
index 2ec0dd3..673d1b3 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1235,7 +1235,7 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
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;
@@ -1304,14 +1304,14 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
path = PySys_GetObject("path");
}
if (path == NULL || !PyList_Check(path)) {
- 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;
@@ -1319,7 +1319,7 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
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;
}