mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #13560: os.strerror() now uses the current locale encoding instead of UTF-8
This commit is contained in:
parent
f2ea71fcc8
commit
1f33f2b0c3
5 changed files with 35 additions and 20 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue