[Python-checkins] r85709 - python/branches/py3k/Python/pythonrun.c

victor.stinner python-checkins at python.org
Tue Oct 19 02:05:51 CEST 2010


Author: victor.stinner
Date: Tue Oct 19 02:05:51 2010
New Revision: 85709

Log:
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.


Modified:
   python/branches/py3k/Python/pythonrun.c

Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c	(original)
+++ python/branches/py3k/Python/pythonrun.c	Tue Oct 19 02:05:51 2010
@@ -730,21 +730,14 @@
         /* 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
 


More information about the Python-checkins mailing list