summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-26 22:24:21 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-26 22:24:21 (GMT)
commit793b531756a4752a167e29f53c4ff49ce2846c74 (patch)
tree30451bc81f557d0613390ea4a9b6b4298d15c9d3 /Python/pythonrun.c
parentc40a350db0f16c678273ee715fe7c70c431360a1 (diff)
downloadcpython-793b531756a4752a167e29f53c4ff49ce2846c74.zip
cpython-793b531756a4752a167e29f53c4ff49ce2846c74.tar.gz
cpython-793b531756a4752a167e29f53c4ff49ce2846c74.tar.bz2
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.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 99bd66d..ad31613 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -53,7 +53,7 @@ extern grammar _PyParser_Grammar; /* From graminit.c */
/* 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);
@@ -298,7 +298,8 @@ Py_InitializeEx(int install_sigs)
_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() */
@@ -618,6 +619,10 @@ Py_NewInterpreter(void)
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");
@@ -730,8 +735,8 @@ initmain(void)
}
}
-static void
-initfsencoding(void)
+static int
+initfsencoding(PyInterpreterState *interp)
{
PyObject *codec;
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
@@ -748,7 +753,8 @@ initfsencoding(void)
Py_FileSystemDefaultEncoding = codeset;
Py_HasFileSystemDefaultEncoding = 0;
- return;
+ interp->fscodec_initialized = 1;
+ return 0;
}
#endif
@@ -758,10 +764,11 @@ initfsencoding(void)
/* 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) */