Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 61593:47b4da86b9b9
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.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Sat, 15 May 2010 12:27:16 +0000 |
| parents | cab14be0ada1 |
| children | 846866aa0eb6 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Sat May 15 09:41:27 2010 +0000 +++ b/Python/bltinmodule.c Sat May 15 12:27:16 2010 +0000 @@ -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 @@ #elif defined(__APPLE__) const char *Py_FileSystemDefaultEncoding = "utf-8"; int Py_HasFileSystemDefaultEncoding = 1; +#elif defined(HAVE_LANGINFO_H) && defined(CODESET) +const char *Py_FileSystemDefaultEncoding = NULL; /* set by initfsencoding() */ +int Py_HasFileSystemDefaultEncoding = 0; #else -const char *Py_FileSystemDefaultEncoding = NULL; /* use default */ -int Py_HasFileSystemDefaultEncoding = 0; +const char *Py_FileSystemDefaultEncoding = "utf-8"; +int Py_HasFileSystemDefaultEncoding = 1; #endif int
