summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-19 00:05:51 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-19 00:05:51 (GMT)
commite474309bb7f0ba6e6ae824c215c45f00db691889 (patch)
treef1e5280c76debfeb347f05b399ce99a2330ecf9e
parent07298a1f0434950c927f5d459fe611f73bb6d262 (diff)
downloadcpython-e474309bb7f0ba6e6ae824c215c45f00db691889.zip
cpython-e474309bb7f0ba6e6ae824c215c45f00db691889.tar.gz
cpython-e474309bb7f0ba6e6ae824c215c45f00db691889.tar.bz2
initfsencoding(): get_codeset() failure is now a fatal error
Don't fallback to utf-8 anymore to avoid mojibake. I never got any error from his function.
-rw-r--r--Python/pythonrun.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index fe99fd2..f755d11 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -730,21 +730,14 @@ initfsencoding(void)
/* On Unix, set the file system encoding according to the
user's preference, if the CODESET names a well-known
Python codec, and Py_FileSystemDefaultEncoding isn't
- initialized by other means. Also set the encoding of
- stdin and stdout if these are terminals. */
+ initialized by other means. */
codeset = get_codeset();
- if (codeset != NULL) {
- Py_FileSystemDefaultEncoding = codeset;
- Py_HasFileSystemDefaultEncoding = 0;
- return;
- } else {
- fprintf(stderr, "Unable to get the locale encoding:\n");
- PyErr_Print();
- }
+ if (codeset == NULL)
+ Py_FatalError("Py_Initialize: Unable to get the locale encoding");
- fprintf(stderr, "Unable to get the filesystem encoding: fallback to utf-8\n");
- Py_FileSystemDefaultEncoding = "utf-8";
- Py_HasFileSystemDefaultEncoding = 1;
+ Py_FileSystemDefaultEncoding = codeset;
+ Py_HasFileSystemDefaultEncoding = 0;
+ return;
}
#endif