Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 72387:c9bb16b7d148 2.7
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.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Thu, 15 Sep 2011 19:45:53 +0200 |
| parents | 85a12278de69 |
| children | 0f5b64630fda |
line wrap: on
line diff
--- a/Python/import.c Wed Sep 14 15:19:42 2011 +0200 +++ b/Python/import.c Thu Sep 15 19:45:53 2011 +0200 @@ -1235,7 +1235,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; @@ -1304,14 +1304,14 @@ 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 @@ 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; }
