mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
faulthandler now works in non-Python threads
Issue #26563: * Add _PyGILState_GetInterpreterStateUnsafe() function: the single PyInterpreterState used by this process' GILState implementation. * Enhance _Py_DumpTracebackThreads() to retrieve the interpreter state from autoInterpreterState in last resort. The function now accepts NULL for interp and current_tstate parameters. * test_faulthandler: fix a ResourceWarning when test is interrupted by CTRL+c
This commit is contained in:
parent
c36674a2c5
commit
861d9abfcf
7 changed files with 164 additions and 48 deletions
|
|
@ -1275,25 +1275,11 @@ initstdio(void)
|
|||
static void
|
||||
_Py_FatalError_DumpTracebacks(int fd)
|
||||
{
|
||||
PyThreadState *tstate;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
/* PyGILState_GetThisThreadState() works even if the GIL was released */
|
||||
tstate = PyGILState_GetThisThreadState();
|
||||
#else
|
||||
tstate = PyThreadState_GET();
|
||||
#endif
|
||||
if (tstate == NULL) {
|
||||
/* _Py_DumpTracebackThreads() requires the thread state to display
|
||||
* frames */
|
||||
return;
|
||||
}
|
||||
|
||||
fputc('\n', stderr);
|
||||
fflush(stderr);
|
||||
|
||||
/* display the current Python stack */
|
||||
_Py_DumpTracebackThreads(fd, tstate->interp, tstate);
|
||||
_Py_DumpTracebackThreads(fd, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Print the current exception (if an exception is set) with its traceback,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue