diff Modules/python.c @ 65270:3335edce48a3

Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of the locale encoding.
author Victor Stinner <victor.stinner@haypocalc.com>
date Wed, 13 Oct 2010 22:15:06 +0000
parents cab14be0ada1
children e9ea09787a35
line wrap: on
line diff
--- a/Modules/python.c	Wed Oct 13 22:06:39 2010 +0000
+++ b/Modules/python.c	Wed Oct 13 22:15:06 2010 +0000
@@ -41,7 +41,15 @@
     oldloc = strdup(setlocale(LC_ALL, NULL));
     setlocale(LC_ALL, "");
     for (i = 0; i < argc; i++) {
-        argv_copy2[i] = argv_copy[i] = _Py_char2wchar(argv[i]);
+#ifdef __APPLE__
+        /* Use utf-8 on Mac OS X */
+        PyObject *unicode = PyUnicode_FromString(argv[i]);
+        argv_copy[i] = PyUnicode_AsWideCharString(unicode, NULL);
+        Py_DECREF(unicode);
+#else
+        argv_copy[i] = _Py_char2wchar(argv[i]);
+#endif
+        argv_copy2[i] = argv_copy[i];
         if (!argv_copy[i])
             return 1;
     }