summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-12-17 03:45:09 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-12-17 03:45:09 (GMT)
commit1f33f2b0c381337d5991c227652d65eadd168209 (patch)
tree4f2303936f90a15a9d7a132a3d5f57c238eba38d /Python/errors.c
parentf2ea71fcc8986101512265b685d8d3dfdf7b7bdb (diff)
downloadcpython-1f33f2b0c381337d5991c227652d65eadd168209.zip
cpython-1f33f2b0c381337d5991c227652d65eadd168209.tar.gz
cpython-1f33f2b0c381337d5991c227652d65eadd168209.tar.bz2
Issue #13560: os.strerror() now uses the current locale encoding instead of UTF-8
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 36b8c54..122e444 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -343,9 +343,7 @@ PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
PyObject *message;
PyObject *v, *args;
int i = errno;
-#ifndef MS_WINDOWS
- char *s;
-#else
+#ifdef MS_WINDOWS
WCHAR *s_buf = NULL;
#endif /* Unix/Windows */
@@ -355,11 +353,14 @@ PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
#endif
#ifndef MS_WINDOWS
- if (i == 0)
- s = "Error"; /* Sometimes errno didn't get set */
- else
- s = strerror(i);
- message = PyUnicode_DecodeUTF8(s, strlen(s), "ignore");
+ if (i != 0) {
+ char *s = strerror(i);
+ message = PyUnicode_DecodeLocale(s, 1);
+ }
+ else {
+ /* Sometimes errno didn't get set */
+ message = PyUnicode_FromString("Error");
+ }
#else
if (i == 0)
message = PyUnicode_FromString("Error"); /* Sometimes errno didn't get set */