Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 727:9a754486ef0b legacy-trunk
Print messages about where from modules are imported when -v is given.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 27 Mar 1992 17:21:04 +0000 |
| parents | 5aff9f8fd299 |
| children | 0cd197947d81 |
line wrap: on
line diff
--- a/Python/import.c Fri Mar 27 17:20:21 1992 +0000 +++ b/Python/import.c Fri Mar 27 17:21:04 1992 +0000 @@ -38,6 +38,8 @@ #include "ceval.h" #include "osdefs.h" +extern int verbose; /* Defined in pythonmain.c */ + #ifdef DEBUG #define D(x) x #else @@ -186,6 +188,10 @@ D(fprintf(stderr, "dl_loadmod failed\n")); } else { + if (verbose) + fprintf(stderr, + "import %s # dynamically loaded from \"%s\"\n", + name, namebuf); (*p)(); *m_ret = m = dictlookup(modules, name); if (m == NULL) { @@ -234,10 +240,25 @@ co = (codeobject *)v; } 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'; - 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); + } else err = E_DONE; fclose(fp); @@ -307,7 +328,8 @@ if ((m = dictlookup(modules, name)) == NULL) { if (init_builtin(name)) { if ((m = dictlookup(modules, name)) == NULL) - err_setstr(SystemError, "builtin module missing"); + err_setstr(SystemError, + "builtin module missing"); } else { m = load_module(name); @@ -385,6 +407,9 @@ int i; for (i = 0; inittab[i].name != NULL; i++) { if (strcmp(name, inittab[i].name) == 0) { + if (verbose) + fprintf(stderr, "import %s # builtin\n", + name); (*inittab[i].initfunc)(); return 1; }
