From 90bbaa57f92c48d33a4438f22899847915fb5f56 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 13 Oct 2010 22:15:06 +0000 Subject: Issue #9992: On Mac OS X, decode command line arguments from utf-8 instead of the locale encoding. --- Misc/NEWS | 3 +++ Modules/python.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 142c9fc..06fbe9d 100644 --- 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 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; } -- cgit v0.12