diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-15 19:38:54 +0200 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-15 19:38:54 +0200 |
| commit | 7ac5a3797aae5590c017b16e09f60c79d41679f4 (patch) | |
| tree | 15a5696401a3a1b93aef4ce33b05183484beb289 /Python | |
| parent | cc168ab700b56d1903e374708efe3647037af937 (diff) | |
| parent | dee6b0855426e3641a7119a592f2ff1db69baef3 (diff) | |
| download | cpython-7ac5a3797aae5590c017b16e09f60c79d41679f4.tar.gz | |
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.
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/import.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/import.c b/Python/import.c index 141124830a..7902721a92 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1992,7 +1992,7 @@ find_module(PyObject *fullname, PyObject *name, PyObject *search_path_list, 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 @@ find_module(PyObject *fullname, PyObject *name, PyObject *search_path_list, } 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 @@ find_module(PyObject *fullname, PyObject *name, PyObject *search_path_list, 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; } |
