comparison Python/sysmodule.c @ 61751:b7f71f60437b

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.
author Victor Stinner <victor.stinner@haypocalc.com>
date Wed, 19 May 2010 16:53:30 +0000
parents cab14be0ada1
children 795762b5e0d6
comparison
equal deleted inserted replaced
61749:5bf4a8633c58 61751:b7f71f60437b
1046 return; 1046 return;
1047 PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL); 1047 PyList_SetSlice(warnoptions, 0, PyList_GET_SIZE(warnoptions), NULL);
1048 } 1048 }
1049 1049
1050 void 1050 void
1051 PySys_AddWarnOption(const wchar_t *s) 1051 PySys_AddWarnOptionUnicode(PyObject *unicode)
1052 { 1052 {
1053 PyObject *str;
1054
1055 if (warnoptions == NULL || !PyList_Check(warnoptions)) { 1053 if (warnoptions == NULL || !PyList_Check(warnoptions)) {
1056 Py_XDECREF(warnoptions); 1054 Py_XDECREF(warnoptions);
1057 warnoptions = PyList_New(0); 1055 warnoptions = PyList_New(0);
1058 if (warnoptions == NULL) 1056 if (warnoptions == NULL)
1059 return; 1057 return;
1060 } 1058 }
1061 str = PyUnicode_FromWideChar(s, -1); 1059 PyList_Append(warnoptions, unicode);
1062 if (str != NULL) { 1060 }
1063 PyList_Append(warnoptions, str); 1061
1064 Py_DECREF(str); 1062 void
1065 } 1063 PySys_AddWarnOption(const wchar_t *s)
1064 {
1065 PyObject *unicode;
1066 unicode = PyUnicode_FromWideChar(s, -1);
1067 if (unicode == NULL)
1068 return;
1069 PySys_AddWarnOptionUnicode(unicode);
1070 Py_DECREF(unicode);
1066 } 1071 }
1067 1072
1068 int 1073 int
1069 PySys_HasWarnOptions(void) 1074 PySys_HasWarnOptions(void)
1070 { 1075 {