]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Changed and exported newcodeobject() interface, for ".pyc" files.
authorGuido van Rossum <guido@python.org>
Tue, 4 Jun 1991 19:41:56 +0000 (19:41 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Jun 1991 19:41:56 +0000 (19:41 +0000)
Python/compile.c

index 5fa405d3ba5cca094dcfc153e170196a4eb676b8..76050031552dcbe094d7f14b32e99cf9f20cf130 100644 (file)
@@ -89,14 +89,12 @@ typeobject Codetype = {
        0,              /*tp_as_mapping*/
 };
 
-static codeobject *newcodeobject PROTO((object *, object *, object *, char *));
-
-static codeobject *
+codeobject *
 newcodeobject(code, consts, names, filename)
        object *code;
        object *consts;
        object *names;
-       char *filename;
+       object *filename;
 {
        codeobject *co;
        int i;
@@ -123,10 +121,8 @@ newcodeobject(code, consts, names, filename)
                co->co_consts = consts;
                INCREF(names);
                co->co_names = names;
-               if ((co->co_filename = newstringobject(filename)) == NULL) {
-                       DECREF(co);
-                       co = NULL;
-               }
+               INCREF(filename);
+               co->co_filename = filename;
        }
        return co;
 }
@@ -1869,12 +1865,15 @@ compile(n, filename)
 {
        struct compiling sc;
        codeobject *co;
+       object *v;
        if (!com_init(&sc, filename))
                return NULL;
        compile_node(&sc, n);
        com_done(&sc);
-       if (sc.c_errors == 0)
-               co = newcodeobject(sc.c_code, sc.c_consts, sc.c_names, filename);
+       if (sc.c_errors == 0 && (v = newstringobject(filename)) != NULL) {
+               co = newcodeobject(sc.c_code, sc.c_consts, sc.c_names, v);
+               DECREF(v);
+       }
        else
                co = NULL;
        com_free(&sc);