diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 2 | ||||
-rw-r--r-- | Python/codecs.c | 1 | ||||
-rw-r--r-- | Python/pystate.c | 1 | ||||
-rw-r--r-- | Python/pythonrun.c | 16 | ||||
-rw-r--r-- | Python/sysmodule.c | 2 |
5 files changed, 20 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 8159fe84d5..d7f5084a58 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2282,7 +2282,7 @@ static struct PyModuleDef builtinsmodule = { PyModuleDef_HEAD_INIT, "builtins", builtin_doc, - 0, + -1, /* multiple "initialization" just copies the module dict. */ builtin_methods, NULL, NULL, diff --git a/Python/codecs.c b/Python/codecs.c index 66576c481c..ebddc09d7b 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -869,5 +869,6 @@ static int _PyCodecRegistry_Init(void) return -1; } Py_DECREF(mod); + interp->codecs_initialized = 1; return 0; } diff --git a/Python/pystate.c b/Python/pystate.c index 9479256718..2a9b7443f9 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -76,6 +76,7 @@ PyInterpreterState_New(void) interp->codec_search_path = NULL; interp->codec_search_cache = NULL; interp->codec_error_registry = NULL; + interp->codecs_initialized = 0; #ifdef HAVE_DLOPEN #ifdef RTLD_NOW interp->dlopenflags = RTLD_NOW; diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 4fb2b3e40d..61cdf6d745 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -562,8 +562,13 @@ Py_NewInterpreter(void) goto handle_error; Py_INCREF(interp->builtins); } + + /* initialize builtin exceptions */ + _PyExc_Init(); + sysmod = _PyImport_FindExtension("sys", "sys"); if (bimod != NULL && sysmod != NULL) { + PyObject *pstderr; interp->sysdict = PyModule_GetDict(sysmod); if (interp->sysdict == NULL) goto handle_error; @@ -571,7 +576,18 @@ Py_NewInterpreter(void) PySys_SetPath(Py_GetPath()); PyDict_SetItemString(interp->sysdict, "modules", interp->modules); + /* Set up a preliminary stderr printer until we have enough + infrastructure for the io module in place. */ + pstderr = PyFile_NewStdPrinter(fileno(stderr)); + if (pstderr == NULL) + Py_FatalError("Py_Initialize: can't set preliminary stderr"); + PySys_SetObject("stderr", pstderr); + PySys_SetObject("__stderr__", pstderr); + _PyImportHooks_Init(); + if (initstdio() < 0) + Py_FatalError( + "Py_Initialize: can't initialize sys standard streams"); initmain(); if (!Py_NoSiteFlag) initsite(); diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 952f7e5904..af960bc070 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1231,7 +1231,7 @@ static struct PyModuleDef sysmodule = { PyModuleDef_HEAD_INIT, "sys", sys_doc, - 0, + -1, /* multiple "initialization" just copies the module dict. */ sys_methods, NULL, NULL, |