Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 69708:2caf82aee7a4 3.2
Issue #10914: Initialize correctly the filesystem codec when creating a new
subinterpreter to fix a bootstrap issue with codecs implemented in Python, as
the ISO-8859-15 codec.
Add fscodec_initialized attribute to the PyInterpreterState structure.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Wed, 27 Apr 2011 00:24:21 +0200 |
| parents | 5a983773c09a |
| children | 2a19d09b08f8 ce859b848879 |
line wrap: on
line diff
--- a/Python/pythonrun.c Wed Apr 27 00:20:27 2011 +0200 +++ b/Python/pythonrun.c Wed Apr 27 00:24:21 2011 +0200 @@ -53,7 +53,7 @@ /* Forward */ static void initmain(void); -static void initfsencoding(void); +static int initfsencoding(PyInterpreterState *interp); static void initsite(void); static int initstdio(void); static void flush_io(void); @@ -291,7 +291,8 @@ _PyTime_Init(); - initfsencoding(); + if (initfsencoding(interp) < 0) + Py_FatalError("Py_Initialize: unable to load the file system codec"); if (install_sigs) initsigs(); /* Signal handling stuff, including initintr() */ @@ -608,6 +609,10 @@ Py_DECREF(pstderr); _PyImportHooks_Init(); + + if (initfsencoding(interp) < 0) + goto handle_error; + if (initstdio() < 0) Py_FatalError( "Py_Initialize: can't initialize sys standard streams"); @@ -720,8 +725,8 @@ } } -static void -initfsencoding(void) +static int +initfsencoding(PyInterpreterState *interp) { PyObject *codec; #if defined(HAVE_LANGINFO_H) && defined(CODESET) @@ -738,7 +743,8 @@ Py_FileSystemDefaultEncoding = codeset; Py_HasFileSystemDefaultEncoding = 0; - return; + interp->fscodec_initialized = 1; + return 0; } #endif @@ -748,10 +754,11 @@ /* Such error can only occurs in critical situations: no more * memory, import a module of the standard library failed, * etc. */ - Py_FatalError("Py_Initialize: unable to load the file system codec"); - } else { - Py_DECREF(codec); + return -1; } + Py_DECREF(codec); + interp->fscodec_initialized = 1; + return 0; } /* Import the site module (not into __main__ though) */
