mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Print messages about where from modules are imported when -v is given.
This commit is contained in:
parent
2bac4d3368
commit
4cd8b5cad8
1 changed files with 27 additions and 2 deletions
|
@ -38,6 +38,8 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "ceval.h"
|
#include "ceval.h"
|
||||||
#include "osdefs.h"
|
#include "osdefs.h"
|
||||||
|
|
||||||
|
extern int verbose; /* Defined in pythonmain.c */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define D(x) x
|
#define D(x) x
|
||||||
#else
|
#else
|
||||||
|
@ -186,6 +188,10 @@ get_module(m, name, m_ret)
|
||||||
D(fprintf(stderr, "dl_loadmod failed\n"));
|
D(fprintf(stderr, "dl_loadmod failed\n"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,
|
||||||
|
"import %s # dynamically loaded from \"%s\"\n",
|
||||||
|
name, namebuf);
|
||||||
(*p)();
|
(*p)();
|
||||||
*m_ret = m = dictlookup(modules, name);
|
*m_ret = m = dictlookup(modules, name);
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
|
@ -234,10 +240,25 @@ get_module(m, name, m_ret)
|
||||||
co = (codeobject *)v;
|
co = (codeobject *)v;
|
||||||
}
|
}
|
||||||
fclose(fpc);
|
fclose(fpc);
|
||||||
|
if (verbose) {
|
||||||
|
if (co != NULL)
|
||||||
|
fprintf(stderr,
|
||||||
|
"import %s # precompiled from \"%s\"\n",
|
||||||
|
name, namebuf);
|
||||||
|
else
|
||||||
|
fprintf(stderr,
|
||||||
|
"# invalid precompiled file \"%s\"\n",
|
||||||
|
namebuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
namebuf[namelen] = '\0';
|
namebuf[namelen] = '\0';
|
||||||
if (co == NULL)
|
if (co == NULL) {
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr,
|
||||||
|
"import %s # from \"%s\"\n",
|
||||||
|
name, namebuf);
|
||||||
err = parse_file(fp, namebuf, file_input, &n);
|
err = parse_file(fp, namebuf, file_input, &n);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
err = E_DONE;
|
err = E_DONE;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -307,7 +328,8 @@ import_module(name)
|
||||||
if ((m = dictlookup(modules, name)) == NULL) {
|
if ((m = dictlookup(modules, name)) == NULL) {
|
||||||
if (init_builtin(name)) {
|
if (init_builtin(name)) {
|
||||||
if ((m = dictlookup(modules, name)) == NULL)
|
if ((m = dictlookup(modules, name)) == NULL)
|
||||||
err_setstr(SystemError, "builtin module missing");
|
err_setstr(SystemError,
|
||||||
|
"builtin module missing");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m = load_module(name);
|
m = load_module(name);
|
||||||
|
@ -385,6 +407,9 @@ init_builtin(name)
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; inittab[i].name != NULL; i++) {
|
for (i = 0; inittab[i].name != NULL; i++) {
|
||||||
if (strcmp(name, inittab[i].name) == 0) {
|
if (strcmp(name, inittab[i].name) == 0) {
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr, "import %s # builtin\n",
|
||||||
|
name);
|
||||||
(*inittab[i].initfunc)();
|
(*inittab[i].initfunc)();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue