diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-19 16:53:30 +0000 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-19 16:53:30 +0000 |
commit | 1d7bed6f68baa1ba111dc0d51b92d4f2bb0fc842 (patch) | |
tree | 7b0852d786479ec97d8b6826c903f183f2e2ee6f /Modules/main.c | |
parent | 62933939c725b2e0f2719da959eae0c0403a82b6 (diff) | |
download | cpython-1d7bed6f68baa1ba111dc0d51b92d4f2bb0fc842.tar.gz |
Issue #8589: Decode PYTHONWARNINGS environment variable with the file system
encoding and surrogateespace error handler instead of the locale encoding to be
consistent with os.environ. Add PySys_AddWarnOptionUnicode() function.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/main.c b/Modules/main.c index 92b971fb0f..29f5fc82e6 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -425,7 +425,7 @@ Py_Main(int argc, wchar_t **argv) #else if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') { char *buf, *oldloc; - wchar_t *warning; + PyObject *warning; /* settle for strtok here as there's no one standard C89 wcstok */ @@ -437,9 +437,10 @@ 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, ",")) { - if ((warning = _Py_char2wchar(p)) != NULL) { - PySys_AddWarnOption(warning); - PyMem_Free(warning); + warning = PyUnicode_DecodeFSDefault(p); + if (warning != NULL) { + PySys_AddWarnOptionUnicode(warning); + Py_DECREF(warning); } } setlocale(LC_ALL, oldloc); |