]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
import.c: When something is wrong with the .pyc, properly open the .py
authorSjoerd Mullender <sjoerd@acm.org>
Mon, 25 Oct 1993 08:40:52 +0000 (08:40 +0000)
committerSjoerd Mullender <sjoerd@acm.org>
Mon, 25 Oct 1993 08:40:52 +0000 (08:40 +0000)
file.
object.c: Write allocation statistics to stderr.

Objects/object.c
Python/import.c

index f2d801bb6584b6aaf28812038000c7d13d91ed86..73fba504595e7146e62c935b37a363c160e21196 100644 (file)
@@ -45,14 +45,15 @@ dump_counts()
        typeobject *tp;
 
        for (tp = type_list; tp; tp = tp->tp_next)
-               printf("%s alloc'd: %d, freed: %d, max in use: %d\n",
-                      tp->tp_name, tp->tp_alloc, tp->tp_free,
-                      tp->tp_maxalloc);
-       printf("fast tuple allocs: %d, empty: %d\n", fast_tuple_allocs,
-              tuple_zero_allocs);
-       printf("fast int allocs: pos: %d, neg: %d\n", quick_int_allocs,
-              quick_neg_int_allocs);
-       printf("null strings: %d, 1-strings: %d\n", null_strings, one_strings);
+               fprintf(stderr, "%s alloc'd: %d, freed: %d, max in use: %d\n",
+                       tp->tp_name, tp->tp_alloc, tp->tp_free,
+                       tp->tp_maxalloc);
+       fprintf(stderr, "fast tuple allocs: %d, empty: %d\n",
+               fast_tuple_allocs, tuple_zero_allocs);
+       fprintf(stderr, "fast int allocs: pos: %d, neg: %d\n",
+               quick_int_allocs, quick_neg_int_allocs);
+       fprintf(stderr, "null strings: %d, 1-strings: %d\n",
+               null_strings, one_strings);
 }
 
 void
index f0d4828ea0177e6ed36cfd1a192763c05c283353..c0f163ae6ca7a6904dbddf0c316ba0d502399443 100644 (file)
@@ -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);