Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Oct 28, 2025

Add _Py_DumpWideString() function to dump a wide string as ASCII. It supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString() in write_thread_name().

Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().
@vstinner
Copy link
Member Author

Example:

import _thread
_thread.set_name('a \xe9 \u20ac \U0010abcd .')
import faulthandler
def f():
    faulthandler.dump_traceback()
f()

Output:

Current thread 0x00000ab8 [a \xe9 \u20ac \U0010abcd .] (most recent call first):
  File "C:\victor\python\main\x.py", line 5 in f
  File "C:\victor\python\main\x.py", line 6 in <module>

where \U0010abcd is encoded as a surrogate pair.

@vstinner vstinner merged commit 80f20f5 into python:main Oct 28, 2025
48 checks passed
@vstinner vstinner deleted the faulthandler_wstr branch October 28, 2025 13:41
vstinner added a commit to vstinner/cpython that referenced this pull request Nov 27, 2025
python#140700)

Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().

(cherry picked from commit 80f20f5)
vstinner added a commit that referenced this pull request Nov 27, 2025
…2011)

* gh-125434: Display thread name in faulthandler on Windows (#140675)

(cherry picked from commit 313145e)

* gh-125434: Fix non-ASCII thread names in faulthandler on Windows (#140700)

Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().

(cherry picked from commit 80f20f5)
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
python#140700)

Add _Py_DumpWideString() function to dump a wide string as ASCII. It
supports surrogate pairs.

Replace _Py_EncodeLocaleRaw() with _Py_DumpWideString()
in write_thread_name().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant