summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-15 12:27:16 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-15 12:27:16 (GMT)
commitb744ba1d14c5487576c95d0311e357b707600b47 (patch)
tree8730e891809884fd8b458b65e7d4bb26ebf6ef0e /Python/bltinmodule.c
parent06ba9ade85be733e4c6c3708c088317068ae20d9 (diff)
downloadcpython-b744ba1d14c5487576c95d0311e357b707600b47.zip
cpython-b744ba1d14c5487576c95d0311e357b707600b47.tar.gz
cpython-b744ba1d14c5487576c95d0311e357b707600b47.tar.bz2
Issue #8610: Load file system codec at startup, and display a fatal error on
failure. Set the file system encoding to utf-8 (instead of None) if getting the locale encoding failed, or if nl_langinfo(CODESET) function is missing.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 97f7b96..a658f9b 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -9,6 +9,10 @@
#include <ctype.h>
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h> /* CODESET */
+#endif
+
/* The default encoding used by the platform file system APIs
Can remain NULL for all platforms that don't have such a concept
@@ -21,9 +25,12 @@ int Py_HasFileSystemDefaultEncoding = 1;
#elif defined(__APPLE__)
const char *Py_FileSystemDefaultEncoding = "utf-8";
int Py_HasFileSystemDefaultEncoding = 1;
-#else
-const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
+#elif defined(HAVE_LANGINFO_H) && defined(CODESET)
+const char *Py_FileSystemDefaultEncoding = NULL; /* set by initfsencoding() */
int Py_HasFileSystemDefaultEncoding = 0;
+#else
+const char *Py_FileSystemDefaultEncoding = "utf-8";
+int Py_HasFileSystemDefaultEncoding = 1;
#endif
int