summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-13 22:15:06 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-13 22:15:06 (GMT)
commit90bbaa57f92c48d33a4438f22899847915fb5f56 (patch)
treed411404e57c891facb06ccddbf4142cb886bd73c /Modules
parenteb1410fc40e07d71c51b781ea2436f9e5ad90178 (diff)
downloadcpython-90bbaa57f92c48d33a4438f22899847915fb5f56.zip
cpython-90bbaa57f92c48d33a4438f22899847915fb5f56.tar.gz
cpython-90bbaa57f92c48d33a4438f22899847915fb5f56.tar.bz2
Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of
the locale encoding.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/python.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Modules/python.c b/Modules/python.c
index 22fbdb5..540bcfe 100644
--- a/Modules/python.c
+++ b/Modules/python.c
@@ -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;
}