mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-138004: Fix setting a thread name on OpenIndiana (GH-138017) (#138384)
gh-138004: Fix setting a thread name on OpenIndiana (GH-138017)
Encode Solaris/Illumos thread names to ASCII, since
OpenIndiana does not support non-ASCII names.
Add tests for setting non-ASCII name for the main thread.
(cherry picked from commit c19db1d2b8)
Co-authored-by: jadonduff <jadon_duff@icloud.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
a893270c6d
commit
ffc67b3505
4 changed files with 19 additions and 6 deletions
|
|
@ -2474,7 +2474,9 @@ _thread__get_name_impl(PyObject *module)
|
|||
}
|
||||
|
||||
#ifdef __sun
|
||||
return PyUnicode_DecodeUTF8(name, strlen(name), "surrogateescape");
|
||||
// gh-138004: Decode Solaris/Illumos (e.g. OpenIndiana) thread names
|
||||
// from ASCII, since OpenIndiana only supports ASCII names.
|
||||
return PyUnicode_DecodeASCII(name, strlen(name), "surrogateescape");
|
||||
#else
|
||||
return PyUnicode_DecodeFSDefault(name);
|
||||
#endif
|
||||
|
|
@ -2512,8 +2514,9 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
|
|||
{
|
||||
#ifndef MS_WINDOWS
|
||||
#ifdef __sun
|
||||
// Solaris always uses UTF-8
|
||||
const char *encoding = "utf-8";
|
||||
// gh-138004: Encode Solaris/Illumos thread names to ASCII,
|
||||
// since OpenIndiana does not support non-ASCII names.
|
||||
const char *encoding = "ascii";
|
||||
#else
|
||||
// Encode the thread name to the filesystem encoding using the "replace"
|
||||
// error handler
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue