Issue #13560: os.strerror() now uses the current locale encoding instead of UTF-8

This commit is contained in:
Victor Stinner 2011-12-17 04:45:09 +01:00
parent f2ea71fcc8
commit 1f33f2b0c3
5 changed files with 35 additions and 20 deletions

View file

@ -7891,7 +7891,7 @@ posix_strerror(PyObject *self, PyObject *args)
"strerror() argument out of range");
return NULL;
}
return PyUnicode_FromString(message);
return PyUnicode_DecodeLocale(message, 1);
}

View file

@ -4032,9 +4032,8 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
if (h->h_addrtype != af) {
/* Let's get real error message to return */
PyErr_SetString(PyExc_OSError,
(char *)strerror(EAFNOSUPPORT));
errno = EAFNOSUPPORT;
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}