summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-09-12 08:00:41 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-09-12 08:00:41 (GMT)
commit5c848a84fd59eabd1ab9965d376b78139eaf97f7 (patch)
treeb870d5b86121f6d9c0cc6016a671989f32b7c300 /Modules/main.c
parent4c7db315df75bdd014041b12122a34cf9f034754 (diff)
downloadcpython-5c848a84fd59eabd1ab9965d376b78139eaf97f7.zip
cpython-5c848a84fd59eabd1ab9965d376b78139eaf97f7.tar.gz
cpython-5c848a84fd59eabd1ab9965d376b78139eaf97f7.tar.bz2
Isse #8589: Decode PYTHONWARNINGS from utf-8 on Mac OS X
Instead of the locale encoding.
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 71fb6fa..0043d85 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -488,7 +488,6 @@ Py_Main(int argc, wchar_t **argv)
#else
if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') {
char *buf, *oldloc;
- wchar_t *wchar;
PyObject *unicode;
/* settle for strtok here as there's no one standard
@@ -501,11 +500,16 @@ Py_Main(int argc, wchar_t **argv)
oldloc = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "");
for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) {
- wchar = _Py_char2wchar(p);
+#ifdef __APPLE__
+ /* Use utf-8 on Mac OS X */
+ unicode = PyUnicode_FromString(p);
+#else
+ wchar_t *wchar = _Py_char2wchar(p);
if (wchar == NULL)
continue;
unicode = PyUnicode_FromWideChar(wchar, wcslen(wchar));
PyMem_Free(wchar);
+#endif
if (unicode == NULL)
continue;
PySys_AddWarnOptionUnicode(unicode);