diff Modules/main.c @ 64667:ed43ebda35f2

Isse #8589: Decode PYTHONWARNINGS from utf-8 on Mac OS X Instead of the locale encoding.
author Victor Stinner <victor.stinner@haypocalc.com>
date Sun, 12 Sep 2010 08:00:41 +0000
parents 586a411cac7c
children f237fde925fa
line wrap: on
line diff
--- a/Modules/main.c	Sun Sep 12 07:51:18 2010 +0000
+++ b/Modules/main.c	Sun Sep 12 08:00:41 2010 +0000
@@ -488,7 +488,6 @@
 #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 @@
         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);