summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-19 16:53:30 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-19 16:53:30 +0000
commit1d7bed6f68baa1ba111dc0d51b92d4f2bb0fc842 (patch)
tree7b0852d786479ec97d8b6826c903f183f2e2ee6f /Python/sysmodule.c
parent62933939c725b2e0f2719da959eae0c0403a82b6 (diff)
downloadcpython-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 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ac14751506..ce06d7d3fe 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