]> granicus.if.org Git - python/commitdiff
initfsencoding(): get_codeset() failure is now a fatal error
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 19 Oct 2010 00:05:51 +0000 (00:05 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 19 Oct 2010 00:05:51 +0000 (00:05 +0000)
Don't fallback to utf-8 anymore to avoid mojibake. I never got any error from
his function.

Python/pythonrun.c

index fe99fd23f4caa824ecc2098977709ff32aed3ffe..f755d117fffe6f9575613aae04dbbafe634c3492 100644 (file)
@@ -730,21 +730,14 @@ initfsencoding(void)
         /* On Unix, set the file system encoding according to the
            user's preference, if the CODESET names a well-known
            Python codec, and Py_FileSystemDefaultEncoding isn't
-           initialized by other means. Also set the encoding of
-           stdin and stdout if these are terminals.  */
+           initialized by other means. */
         codeset = get_codeset();
-        if (codeset != NULL) {
-            Py_FileSystemDefaultEncoding = codeset;
-            Py_HasFileSystemDefaultEncoding = 0;
-            return;
-        } else {
-            fprintf(stderr, "Unable to get the locale encoding:\n");
-            PyErr_Print();
-        }
+        if (codeset == NULL)
+            Py_FatalError("Py_Initialize: Unable to get the locale encoding");
 
-        fprintf(stderr, "Unable to get the filesystem encoding: fallback to utf-8\n");
-        Py_FileSystemDefaultEncoding = "utf-8";
-        Py_HasFileSystemDefaultEncoding = 1;
+        Py_FileSystemDefaultEncoding = codeset;
+        Py_HasFileSystemDefaultEncoding = 0;
+        return;
     }
 #endif