summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>1993-10-25 08:40:52 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>1993-10-25 08:40:52 (GMT)
commit52c1f515547a96898879fe60e2432b69ff95cca0 (patch)
tree294896c67c57a218d91b6c2b11aa38187b3f7cef /Python/import.c
parent89b3325dc4d6999bb00068e048a76f7eba23a7a5 (diff)
downloadcpython-52c1f515547a96898879fe60e2432b69ff95cca0.zip
cpython-52c1f515547a96898879fe60e2432b69ff95cca0.tar.gz
cpython-52c1f515547a96898879fe60e2432b69ff95cca0.tar.bz2
import.c: When something is wrong with the .pyc, properly open the .py
file. object.c: Write allocation statistics to stderr.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/Python/import.c b/Python/import.c
index f0d4828..c0f163a 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -228,7 +228,6 @@ get_module(m, name, m_ret)
pyc_mtime = rd_long(fpc);
if (mtime != -1 && mtime > pyc_mtime) {
fclose(fpc);
- fp = fopen(namebuf, "rb");
goto read_py;
}
if (magic == MAGIC) {
@@ -247,40 +246,46 @@ get_module(m, name, m_ret)
fprintf(stderr,
"import %s # precompiled from \"%s\"\n",
name, namebuf);
- else
+ else {
fprintf(stderr,
"# invalid precompiled file \"%s\"\n",
namebuf);
- }
- }
- else if ((fp = find_module(name, PY_SUFFIX, "r",
- namebuf, &mtime)) != NULL) {
-read_py:
- namelen = strlen(namebuf);
- if (co == NULL) {
- if (verbose)
- fprintf(stderr,
- "import %s # from \"%s\"\n",
- name, namebuf);
- err = parse_file(fp, namebuf, file_input, &n);
- } else
- err = E_DONE;
- fclose(fp);
- if (err != E_DONE) {
- err_input(err);
- return NULL;
+ goto read_py;
+ }
}
}
else {
- if (m == NULL) {
- sprintf(namebuf, "no module named %.200s", name);
- err_setstr(ImportError, namebuf);
+read_py:
+ if ((fp = find_module(name, PY_SUFFIX, "r",
+ namebuf, &mtime)) != NULL) {
+ namelen = strlen(namebuf);
+ if (co == NULL) {
+ if (verbose)
+ fprintf(stderr,
+ "import %s # from \"%s\"\n",
+ name, namebuf);
+ err = parse_file(fp, namebuf, file_input, &n);
+ } else
+ err = E_DONE;
+ fclose(fp);
+ if (err != E_DONE) {
+ err_input(err);
+ return NULL;
+ }
}
else {
- sprintf(namebuf, "no source for module %.200s", name);
- err_setstr(ImportError, namebuf);
+ 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;
}
- return NULL;
}
if (m == NULL) {
m = add_module(name);