mirror of
https://github.com/python/cpython.git
synced 2025-09-18 06:30:38 +00:00
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.
This commit is contained in:
parent
07298a1f04
commit
e474309bb7
1 changed files with 6 additions and 13 deletions
|
@ -730,21 +730,14 @@ initfsencoding(void)
|
||||||
/* On Unix, set the file system encoding according to the
|
/* On Unix, set the file system encoding according to the
|
||||||
user's preference, if the CODESET names a well-known
|
user's preference, if the CODESET names a well-known
|
||||||
Python codec, and Py_FileSystemDefaultEncoding isn't
|
Python codec, and Py_FileSystemDefaultEncoding isn't
|
||||||
initialized by other means. Also set the encoding of
|
initialized by other means. */
|
||||||
stdin and stdout if these are terminals. */
|
|
||||||
codeset = get_codeset();
|
codeset = get_codeset();
|
||||||
if (codeset != NULL) {
|
if (codeset == NULL)
|
||||||
Py_FileSystemDefaultEncoding = codeset;
|
Py_FatalError("Py_Initialize: Unable to get the locale encoding");
|
||||||
Py_HasFileSystemDefaultEncoding = 0;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Unable to get the locale encoding:\n");
|
|
||||||
PyErr_Print();
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "Unable to get the filesystem encoding: fallback to utf-8\n");
|
Py_FileSystemDefaultEncoding = codeset;
|
||||||
Py_FileSystemDefaultEncoding = "utf-8";
|
Py_HasFileSystemDefaultEncoding = 0;
|
||||||
Py_HasFileSystemDefaultEncoding = 1;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue