mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
PyUnicode_DecodeFSDefaultAndSize() uses surrogateescape error handler
This function is only used to decode Python module filenames, but Python doesn't support surrogates in modules filenames yet. So nobody noticed this minor bug.
This commit is contained in:
parent
56d6410c2d
commit
b9a20ad036
2 changed files with 6 additions and 4 deletions
|
@ -1600,19 +1600,19 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
|
|||
if (Py_FileSystemDefaultEncoding) {
|
||||
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
|
||||
if (strcmp(Py_FileSystemDefaultEncoding, "mbcs") == 0) {
|
||||
return PyUnicode_DecodeMBCS(s, size, "replace");
|
||||
return PyUnicode_DecodeMBCS(s, size, "surrogateescape");
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
if (strcmp(Py_FileSystemDefaultEncoding, "utf-8") == 0) {
|
||||
return PyUnicode_DecodeUTF8(s, size, "replace");
|
||||
return PyUnicode_DecodeUTF8(s, size, "surrogateescape");
|
||||
}
|
||||
#endif
|
||||
return PyUnicode_Decode(s, size,
|
||||
Py_FileSystemDefaultEncoding,
|
||||
"replace");
|
||||
"surrogateescape");
|
||||
}
|
||||
else {
|
||||
return PyUnicode_DecodeUTF8(s, size, "replace");
|
||||
return PyUnicode_DecodeUTF8(s, size, "surrogateescape");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue