]> granicus.if.org Git - python/commitdiff
Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 13 Oct 2010 22:15:06 +0000 (22:15 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 13 Oct 2010 22:15:06 +0000 (22:15 +0000)
the locale encoding.

Misc/NEWS
Modules/python.c

index 142c9fc34ef64742ea556420875def9b9eacfb7e..06fbe9d2d98216679a7ca828f6a670708d02a53e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1?
 Core and Builtins
 -----------------
 
+- Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of
+  the locale encoding.
+
 - Issue #9992: Remove PYTHONFSENCODING environment variable.
 
 Library
index 22fbdb5b0a51c5a8970c1fe27a4a275c7e16575f..540bcfe1a4de5a422501621e619c029ac8346dc2 100644 (file)
@@ -41,7 +41,15 @@ main(int argc, char **argv)
     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;
     }