summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-06-04 19:41:56 (GMT)
committerGuido van Rossum <guido@python.org>1991-06-04 19:41:56 (GMT)
commita082ce40a62e684116049e66c0104263e162694e (patch)
treedc5621dce9c15d69eca33a4a8f156510baf0342d /Python/compile.c
parent3caa6e35cfd8bc08725c4d669b46d19f301f3f85 (diff)
downloadcpython-a082ce40a62e684116049e66c0104263e162694e.zip
cpython-a082ce40a62e684116049e66c0104263e162694e.tar.gz
cpython-a082ce40a62e684116049e66c0104263e162694e.tar.bz2
Changed and exported newcodeobject() interface, for ".pyc" files.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 5fa405d..7605003 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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);