mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
import.c: When something is wrong with the .pyc, properly open the .py
file. object.c: Write allocation statistics to stderr.
This commit is contained in:
parent
89b3325dc4
commit
52c1f51554
2 changed files with 40 additions and 34 deletions
|
@ -45,14 +45,15 @@ dump_counts()
|
||||||
typeobject *tp;
|
typeobject *tp;
|
||||||
|
|
||||||
for (tp = type_list; tp; tp = tp->tp_next)
|
for (tp = type_list; tp; tp = tp->tp_next)
|
||||||
printf("%s alloc'd: %d, freed: %d, max in use: %d\n",
|
fprintf(stderr, "%s alloc'd: %d, freed: %d, max in use: %d\n",
|
||||||
tp->tp_name, tp->tp_alloc, tp->tp_free,
|
tp->tp_name, tp->tp_alloc, tp->tp_free,
|
||||||
tp->tp_maxalloc);
|
tp->tp_maxalloc);
|
||||||
printf("fast tuple allocs: %d, empty: %d\n", fast_tuple_allocs,
|
fprintf(stderr, "fast tuple allocs: %d, empty: %d\n",
|
||||||
tuple_zero_allocs);
|
fast_tuple_allocs, tuple_zero_allocs);
|
||||||
printf("fast int allocs: pos: %d, neg: %d\n", quick_int_allocs,
|
fprintf(stderr, "fast int allocs: pos: %d, neg: %d\n",
|
||||||
quick_neg_int_allocs);
|
quick_int_allocs, quick_neg_int_allocs);
|
||||||
printf("null strings: %d, 1-strings: %d\n", null_strings, one_strings);
|
fprintf(stderr, "null strings: %d, 1-strings: %d\n",
|
||||||
|
null_strings, one_strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -228,7 +228,6 @@ get_module(m, name, m_ret)
|
||||||
pyc_mtime = rd_long(fpc);
|
pyc_mtime = rd_long(fpc);
|
||||||
if (mtime != -1 && mtime > pyc_mtime) {
|
if (mtime != -1 && mtime > pyc_mtime) {
|
||||||
fclose(fpc);
|
fclose(fpc);
|
||||||
fp = fopen(namebuf, "rb");
|
|
||||||
goto read_py;
|
goto read_py;
|
||||||
}
|
}
|
||||||
if (magic == MAGIC) {
|
if (magic == MAGIC) {
|
||||||
|
@ -247,40 +246,46 @@ get_module(m, name, m_ret)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"import %s # precompiled from \"%s\"\n",
|
"import %s # precompiled from \"%s\"\n",
|
||||||
name, namebuf);
|
name, namebuf);
|
||||||
else
|
else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"# invalid precompiled file \"%s\"\n",
|
"# invalid precompiled file \"%s\"\n",
|
||||||
namebuf);
|
namebuf);
|
||||||
}
|
goto read_py;
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m == NULL) {
|
read_py:
|
||||||
sprintf(namebuf, "no module named %.200s", name);
|
if ((fp = find_module(name, PY_SUFFIX, "r",
|
||||||
err_setstr(ImportError, namebuf);
|
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 {
|
else {
|
||||||
sprintf(namebuf, "no source for module %.200s", name);
|
if (m == NULL) {
|
||||||
err_setstr(ImportError, namebuf);
|
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) {
|
if (m == NULL) {
|
||||||
m = add_module(name);
|
m = add_module(name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue