Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 65535:e2ba1249a2f5
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.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 19 Oct 2010 00:05:51 +0000 |
| parents | fd5135cbd928 |
| children | 18989ad44636 |
comparison
equal
deleted
inserted
replaced
| 65534:8912192982cc | 65535:e2ba1249a2f5 |
|---|---|
| 728 | 728 |
| 729 if (Py_FileSystemDefaultEncoding == NULL) { | 729 if (Py_FileSystemDefaultEncoding == NULL) { |
| 730 /* On Unix, set the file system encoding according to the | 730 /* On Unix, set the file system encoding according to the |
| 731 user's preference, if the CODESET names a well-known | 731 user's preference, if the CODESET names a well-known |
| 732 Python codec, and Py_FileSystemDefaultEncoding isn't | 732 Python codec, and Py_FileSystemDefaultEncoding isn't |
| 733 initialized by other means. Also set the encoding of | 733 initialized by other means. */ |
| 734 stdin and stdout if these are terminals. */ | |
| 735 codeset = get_codeset(); | 734 codeset = get_codeset(); |
| 736 if (codeset != NULL) { | 735 if (codeset == NULL) |
| 737 Py_FileSystemDefaultEncoding = codeset; | 736 Py_FatalError("Py_Initialize: Unable to get the locale encoding"); |
| 738 Py_HasFileSystemDefaultEncoding = 0; | 737 |
| 739 return; | 738 Py_FileSystemDefaultEncoding = codeset; |
| 740 } else { | 739 Py_HasFileSystemDefaultEncoding = 0; |
| 741 fprintf(stderr, "Unable to get the locale encoding:\n"); | 740 return; |
| 742 PyErr_Print(); | |
| 743 } | |
| 744 | |
| 745 fprintf(stderr, "Unable to get the filesystem encoding: fallback to utf-8\n"); | |
| 746 Py_FileSystemDefaultEncoding = "utf-8"; | |
| 747 Py_HasFileSystemDefaultEncoding = 1; | |
| 748 } | 741 } |
| 749 #endif | 742 #endif |
| 750 | 743 |
| 751 /* the encoding is mbcs, utf-8 or ascii */ | 744 /* the encoding is mbcs, utf-8 or ascii */ |
| 752 codec = _PyCodec_Lookup(Py_FileSystemDefaultEncoding); | 745 codec = _PyCodec_Lookup(Py_FileSystemDefaultEncoding); |
