summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-06-11 00:36:33 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-06-11 00:36:33 (GMT)
commit7f84ab59523ab7f7d7d288551a459e24718b8c7d (patch)
treeafbf801d34b4e88d473d4c07e05337b8f1a80376 /Python
parent2b293cf1a5dd602025ed01a0a520f005b543c319 (diff)
downloadcpython-7f84ab59523ab7f7d7d288551a459e24718b8c7d.zip
cpython-7f84ab59523ab7f7d7d288551a459e24718b8c7d.tar.gz
cpython-7f84ab59523ab7f7d7d288551a459e24718b8c7d.tar.bz2
Issue #8965: initfsencoding() doesn't change the encoding on Mac OS X
File system encoding have to be hardcoded to "utf-8" on Mac OS X. r81190 introduced a regression: the encoding was changed depending on the locale.
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 05a9800..5b7cd20 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -703,24 +703,26 @@ initfsencoding(void)
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
char *codeset;
- /* 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. */
- codeset = get_codeset();
- if (codeset != NULL) {
- Py_FileSystemDefaultEncoding = codeset;
- Py_HasFileSystemDefaultEncoding = 0;
- return;
- }
+ if (Py_FileSystemDefaultEncoding == NULL) {
+ /* 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. */
+ codeset = get_codeset();
+ if (codeset != NULL) {
+ Py_FileSystemDefaultEncoding = codeset;
+ Py_HasFileSystemDefaultEncoding = 0;
+ return;
+ }
- PyErr_Clear();
- fprintf(stderr,
- "Unable to get the locale encoding: "
- "fallback to utf-8\n");
- Py_FileSystemDefaultEncoding = "utf-8";
- Py_HasFileSystemDefaultEncoding = 1;
+ PyErr_Clear();
+ fprintf(stderr,
+ "Unable to get the locale encoding: "
+ "fallback to utf-8\n");
+ Py_FileSystemDefaultEncoding = "utf-8";
+ Py_HasFileSystemDefaultEncoding = 1;
+ }
#endif
/* the encoding is mbcs, utf-8 or ascii */