From: Guido van Rossum Date: Tue, 24 Dec 1991 13:26:56 +0000 (+0000) Subject: Use IOError and ImportError when import fails. X-Git-Tag: v0.9.8~673 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4135e782041517e2de473fd9b6f5375878c48e68;p=thirdparty%2FPython%2Fcpython.git Use IOError and ImportError when import fails. --- diff --git a/Python/import.c b/Python/import.c index 77252459d913..0eb44f231133 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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 */