Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 2098:b7be0382f9ee legacy-trunk
__builtins__ mods (and sys_checkinterval for ceval.c)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 09 Jan 1995 17:53:26 +0000 |
| parents | d0d0a69b5ca3 |
| children | 92da8901517e |
line wrap: on
line diff
--- a/Python/pythonrun.c Mon Jan 09 17:50:47 1995 +0000 +++ b/Python/pythonrun.c Mon Jan 09 17:53:26 1995 +0000 @@ -32,6 +32,7 @@ #include "graminit.h" #include "errcode.h" #include "sysmodule.h" +#include "bltinmodule.h" #include "compile.h" #include "eval.h" #include "ceval.h" @@ -48,6 +49,7 @@ extern grammar gram; /* From graminit.c */ /* Forward */ +static void initmain PROTO((void)); static object *run_err_node PROTO((node *n, char *filename, object *globals, object *locals)); static object *run_node PROTO((node *n, char *filename, @@ -83,6 +85,24 @@ setpythonpath(getpythonpath()); initsigs(); /* Signal handling stuff, including initintr() */ + + initmain(); +} + +/* Create __main__ module */ + +static void +initmain() +{ + object *m, *d; + m = add_module("__main__"); + if (m == NULL) + fatal("can't create __main__ module"); + d = getmoduledict(m); + if (dictlookup(d, "__builtins__") == NULL) { + if (dictinsert(d, "__builtins__", getbuiltindict())) + fatal("can't add __builtins__ to __main__"); + } } /* Parse input from a file and execute it */
