diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-19 16:53:30 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-19 16:53:30 (GMT) |
commit | 9ca9c25bcd9d4b771be6fee34a105546d1c8d666 (patch) | |
tree | 1fcc4adff5bc504e451b760d87d30665668e14d7 /Python | |
parent | a5bf3f520c6d899b133b0526a551c279639a7851 (diff) | |
download | cpython-9ca9c25bcd9d4b771be6fee34a105546d1c8d666.zip cpython-9ca9c25bcd9d4b771be6fee34a105546d1c8d666.tar.gz cpython-9ca9c25bcd9d4b771be6fee34a105546d1c8d666.tar.bz2 |
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 'Python')
-rw-r--r-- | Python/sysmodule.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index ac14751..ce06d7d 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1048,21 +1048,26 @@ PySys_ResetWarnOptions(void) } void -PySys_AddWarnOption(const wchar_t *s) +PySys_AddWarnOptionUnicode(PyObject *unicode) { - PyObject *str; - if (warnoptions == NULL || !PyList_Check(warnoptions)) { Py_XDECREF(warnoptions); warnoptions = PyList_New(0); if (warnoptions == NULL) return; } - str = PyUnicode_FromWideChar(s, -1); - if (str != NULL) { - PyList_Append(warnoptions, str); - Py_DECREF(str); - } + PyList_Append(warnoptions, unicode); +} + +void +PySys_AddWarnOption(const wchar_t *s) +{ + PyObject *unicode; + unicode = PyUnicode_FromWideChar(s, -1); + if (unicode == NULL) + return; + PySys_AddWarnOptionUnicode(unicode); + Py_DECREF(unicode); } int |