summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-08-30 08:27:36 (GMT)
committerGuido van Rossum <guido@python.org>1994-08-30 08:27:36 (GMT)
commit1d5735e84621a7fe68d361fa0e289fa2c3310836 (patch)
tree4ee6f32fa4743f4c6641b04131e449bc71a5ea25 /Python/sysmodule.c
parent013142a95fd63a05d09cec7b36b7c86cc98e30c1 (diff)
downloadcpython-1d5735e84621a7fe68d361fa0e289fa2c3310836.zip
cpython-1d5735e84621a7fe68d361fa0e289fa2c3310836.tar.gz
cpython-1d5735e84621a7fe68d361fa0e289fa2c3310836.tar.bz2
Merge back to main trunk
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 2ad8a26..509b819 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -168,16 +168,22 @@ list_builtin_module_names()
addlistitem(list, name);
DECREF(name);
}
+ if (sortlist(list) != 0) {
+ DECREF(list);
+ list = NULL;
+ }
return list;
}
void
initsys()
{
+ extern long getmaxint PROTO((void));
+ extern char *getversion PROTO((void));
+ extern char *getcopyright PROTO((void));
extern int fclose PROTO((FILE *));
- extern char version[];
- object *v = newstringobject(version);
object *m = initmodule("sys", sys_methods);
+ object *v;
sysdict = getmoduledict(m);
INCREF(sysdict);
/* NB keep an extra ref to the std files to avoid closing them
@@ -186,17 +192,21 @@ initsys()
sysout = newopenfileobject(stdout, "<stdout>", "w", fclose);
syserr = newopenfileobject(stderr, "<stderr>", "w", fclose);
if (err_occurred())
- fatal("can't create sys.* objects");
+ fatal("can't initialize sys.std{in,out,err}");
dictinsert(sysdict, "stdin", sysin);
dictinsert(sysdict, "stdout", sysout);
dictinsert(sysdict, "stderr", syserr);
- dictinsert(sysdict, "version", v);
+ dictinsert(sysdict, "version", v = newstringobject(getversion()));
+ XDECREF(v);
+ dictinsert(sysdict, "copyright", v = newstringobject(getcopyright()));
+ XDECREF(v);
+ dictinsert(sysdict, "maxint", v = newintobject(getmaxint()));
+ XDECREF(v);
dictinsert(sysdict, "modules", get_modules());
dictinsert(sysdict, "builtin_module_names",
list_builtin_module_names());
if (err_occurred())
fatal("can't insert sys.* objects in sys dict");
- DECREF(v);
}
static object *