gh-128400: Only show the current thread in Py_FatalError on the free-threaded build (#128758)

This commit is contained in:
Peter Bierma 2025-01-13 09:36:54 -05:00 committed by GitHub
parent 4533036e50
commit bf64a582f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 12 deletions

View file

@ -101,8 +101,7 @@ class FaultHandlerTests(unittest.TestCase):
Raise an error if the output doesn't match the expected format.
"""
all_threads_disabled = (
(not py_fatal_error)
and all_threads
all_threads
and (not sys._is_gil_enabled())
)
if all_threads and not all_threads_disabled:
@ -116,12 +115,15 @@ class FaultHandlerTests(unittest.TestCase):
if py_fatal_error:
regex.append("Python runtime state: initialized")
regex.append('')
if all_threads_disabled:
if all_threads_disabled and not py_fatal_error:
regex.append("<Cannot show all threads while the GIL is disabled>")
regex.append(fr'{header} \(most recent call first\):')
if garbage_collecting and not all_threads_disabled:
regex.append(' Garbage-collecting')
regex.append(fr' File "<string>", line {lineno} in {function}')
if support.Py_GIL_DISABLED and py_fatal_error and not know_current_thread:
regex.append(" <tstate is freed>")
else:
if garbage_collecting and not all_threads_disabled:
regex.append(' Garbage-collecting')
regex.append(fr' File "<string>", line {lineno} in {function}')
regex = '\n'.join(regex)
if other_regex: