mirror of https://github.com/python/cpython.git
gh-121058: Warn if `PyThreadState_Clear` is called with an exception set (gh-121343)
This commit is contained in:
parent
aea0c586d1
commit
6c1a4fb6d4
|
@ -0,0 +1,2 @@
|
|||
``PyThreadState_Clear()`` now warns (and calls ``sys.excepthook``) if the
|
||||
thread state still has an active exception.
|
|
@ -1649,6 +1649,11 @@ PyThreadState_Clear(PyThreadState *tstate)
|
|||
"PyThreadState_Clear: warning: thread still has a frame\n");
|
||||
}
|
||||
|
||||
if (verbose && tstate->current_exception != NULL) {
|
||||
fprintf(stderr, "PyThreadState_Clear: warning: thread has an exception set\n");
|
||||
_PyErr_Print(tstate);
|
||||
}
|
||||
|
||||
/* At this point tstate shouldn't be used any more,
|
||||
neither to run Python code nor for other uses.
|
||||
|
||||
|
|
Loading…
Reference in New Issue