Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Jan 12, 2025
1 parent 3201f79 commit 6418696
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
14 changes: 8 additions & 6 deletions Lib/test/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def check_error(self, code, lineno, fatal_error, *,
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:
Expand All @@ -116,12 +115,15 @@ def check_error(self, code, lineno, fatal_error, *,
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 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:
Expand Down
7 changes: 0 additions & 7 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -3026,13 +3026,6 @@ _Py_FatalError_DumpTracebacks(int fd, PyInterpreterState *interp,
#ifndef Py_GIL_DISABLED
_Py_DumpTracebackThreads(fd, interp, tstate);
#else
if (tstate == NULL)
{
/* _Py_DumpTraceback() prints out a message when tstate is null,
* whereas _Py_DumpTracebackThreads() does not. Early-return for
* consistency. */
return;
}
_Py_DumpTraceback(fd, tstate);
#endif
}
Expand Down

0 comments on commit 6418696

Please sign in to comment.