Changed and exported newcodeobject() interface, for ".pyc" files.
This commit is contained in:
parent
3caa6e35cf
commit
a082ce40a6
@ -89,14 +89,12 @@ typeobject Codetype = {
|
|||||||
0, /*tp_as_mapping*/
|
0, /*tp_as_mapping*/
|
||||||
};
|
};
|
||||||
|
|
||||||
static codeobject *newcodeobject PROTO((object *, object *, object *, char *));
|
codeobject *
|
||||||
|
|
||||||
static codeobject *
|
|
||||||
newcodeobject(code, consts, names, filename)
|
newcodeobject(code, consts, names, filename)
|
||||||
object *code;
|
object *code;
|
||||||
object *consts;
|
object *consts;
|
||||||
object *names;
|
object *names;
|
||||||
char *filename;
|
object *filename;
|
||||||
{
|
{
|
||||||
codeobject *co;
|
codeobject *co;
|
||||||
int i;
|
int i;
|
||||||
@ -123,10 +121,8 @@ newcodeobject(code, consts, names, filename)
|
|||||||
co->co_consts = consts;
|
co->co_consts = consts;
|
||||||
INCREF(names);
|
INCREF(names);
|
||||||
co->co_names = names;
|
co->co_names = names;
|
||||||
if ((co->co_filename = newstringobject(filename)) == NULL) {
|
INCREF(filename);
|
||||||
DECREF(co);
|
co->co_filename = filename;
|
||||||
co = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return co;
|
return co;
|
||||||
}
|
}
|
||||||
@ -1869,12 +1865,15 @@ compile(n, filename)
|
|||||||
{
|
{
|
||||||
struct compiling sc;
|
struct compiling sc;
|
||||||
codeobject *co;
|
codeobject *co;
|
||||||
|
object *v;
|
||||||
if (!com_init(&sc, filename))
|
if (!com_init(&sc, filename))
|
||||||
return NULL;
|
return NULL;
|
||||||
compile_node(&sc, n);
|
compile_node(&sc, n);
|
||||||
com_done(&sc);
|
com_done(&sc);
|
||||||
if (sc.c_errors == 0)
|
if (sc.c_errors == 0 && (v = newstringobject(filename)) != NULL) {
|
||||||
co = newcodeobject(sc.c_code, sc.c_consts, sc.c_names, filename);
|
co = newcodeobject(sc.c_code, sc.c_consts, sc.c_names, v);
|
||||||
|
DECREF(v);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
co = NULL;
|
co = NULL;
|
||||||
com_free(&sc);
|
com_free(&sc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user