mirror of
https://github.com/python/cpython.git
synced 2025-09-01 06:28:36 +00:00
Use IOError and ImportError when import fails.
This commit is contained in:
parent
201be057fb
commit
4135e78204
1 changed files with 8 additions and 4 deletions
|
@ -149,10 +149,14 @@ get_module(m, name, m_ret)
|
|||
|
||||
fp = open_module(name, ".py", namebuf);
|
||||
if (fp == NULL) {
|
||||
if (m == NULL)
|
||||
err_setstr(NameError, name);
|
||||
else
|
||||
err_setstr(IOError, "no module source file");
|
||||
if (m == NULL) {
|
||||
sprintf(namebuf, "no module named %.200s", name);
|
||||
err_setstr(ImportError, namebuf);
|
||||
}
|
||||
else {
|
||||
sprintf(namebuf, "no source for module %.200s", name);
|
||||
err_setstr(ImportError, namebuf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/* Get mtime -- always useful */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue