diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-08-29 21:26:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-29 21:26:55 (GMT) |
commit | de427556746aa41a8b5198924ce423021bc0c718 (patch) | |
tree | 772cffa923cdf523fe79dcccf21e65f1a83b99e5 /Python | |
parent | cf21504194927b2f22132f48effea69eb8ade751 (diff) | |
download | cpython-de427556746aa41a8b5198924ce423021bc0c718.zip cpython-de427556746aa41a8b5198924ce423021bc0c718.tar.gz cpython-de427556746aa41a8b5198924ce423021bc0c718.tar.bz2 |
bpo-34523: Py_FileSystemDefaultEncoding NULL by default (GH-9003)
* Py_FileSystemDefaultEncoding and Py_FileSystemDefaultEncodeErrors
default value is now NULL: initfsencoding() set them
during Python initialization.
* Document how Python chooses the filesystem encoding and error
handler.
* Add an assertion to _PyCoreConfig_Read().
Diffstat (limited to 'Python')
-rw-r--r-- | Python/coreconfig.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c index 625c743..fae32e5 100644 --- a/Python/coreconfig.c +++ b/Python/coreconfig.c @@ -19,25 +19,12 @@ /* Global configuration variables */ -/* The default encoding used by the platform file system APIs - Can remain NULL for all platforms that don't have such a concept - - Don't forget to modify PyUnicode_DecodeFSDefault() if you touch any of the - values for Py_FileSystemDefaultEncoding! -*/ -#if defined(__APPLE__) -const char *Py_FileSystemDefaultEncoding = "utf-8"; -int Py_HasFileSystemDefaultEncoding = 1; -#elif defined(MS_WINDOWS) -/* may be changed by initfsencoding(), but should never be free()d */ -const char *Py_FileSystemDefaultEncoding = "utf-8"; -int Py_HasFileSystemDefaultEncoding = 1; -#else -const char *Py_FileSystemDefaultEncoding = NULL; /* set by initfsencoding() */ +/* The filesystem encoding is chosen by config_init_fs_encoding(), + see also initfsencoding(). */ +const char *Py_FileSystemDefaultEncoding = NULL; int Py_HasFileSystemDefaultEncoding = 0; -#endif -const char *Py_FileSystemDefaultEncodeErrors = "surrogateescape"; -static int _Py_HasFileSystemDefaultEncodeErrors = 1; +const char *Py_FileSystemDefaultEncodeErrors = NULL; +static int _Py_HasFileSystemDefaultEncodeErrors = 0; /* UTF-8 mode (PEP 540): if equals to 1, use the UTF-8 encoding, and change stdin and stdout error handler to "surrogateescape". It is equal to @@ -1362,6 +1349,7 @@ _PyCoreConfig_Read(_PyCoreConfig *config) assert(config->filesystem_errors != NULL); assert(config->stdio_encoding != NULL); assert(config->stdio_errors != NULL); + assert(config->_check_hash_pycs_mode != NULL); return _Py_INIT_OK(); } |