Added sys.version object.

This commit is contained in:
Guido van Rossum 1991-12-10 14:00:21 +00:00
parent 87e7ea72a6
commit 7177657bf2
1 changed files with 5 additions and 1 deletions

View File

@ -115,6 +115,8 @@ void
initsys()
{
extern int fclose PROTO((FILE *));
extern char version[];
object *v = newstringobject(version);
object *m = initmodule("sys", sys_methods);
sysdict = getmoduledict(m);
INCREF(sysdict);
@ -124,13 +126,15 @@ initsys()
sysout = newopenfileobject(stdout, "<stdout>", "w", fclose);
syserr = newopenfileobject(stderr, "<stderr>", "w", fclose);
if (err_occurred())
fatal("can't create sys.std* file objects");
fatal("can't create sys.* objects");
dictinsert(sysdict, "stdin", sysin);
dictinsert(sysdict, "stdout", sysout);
dictinsert(sysdict, "stderr", syserr);
dictinsert(sysdict, "version", v);
dictinsert(sysdict, "modules", get_modules());
if (err_occurred())
fatal("can't insert sys.* objects in sys dict");
DECREF(v);
}
static object *