mirror of
https://github.com/python/cpython.git
synced 2025-09-07 01:11:26 +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);
|
fp = open_module(name, ".py", namebuf);
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
if (m == NULL)
|
if (m == NULL) {
|
||||||
err_setstr(NameError, name);
|
sprintf(namebuf, "no module named %.200s", name);
|
||||||
else
|
err_setstr(ImportError, namebuf);
|
||||||
err_setstr(IOError, "no module source file");
|
}
|
||||||
|
else {
|
||||||
|
sprintf(namebuf, "no source for module %.200s", name);
|
||||||
|
err_setstr(ImportError, namebuf);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Get mtime -- always useful */
|
/* Get mtime -- always useful */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue