diff options
author | Peter Bierma <zintensitydev@gmail.com> | 2024-11-20 12:27:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 10:27:19 -0700 |
commit | 6c1a4fb6d400827155fd70e48d682e35397731a1 (patch) | |
tree | 235d6b3e85d268e1ef49b8fcec7b6fd533d4aa7a /Python/pystate.c | |
parent | aea0c586d181abb897511b6b46d28bfbe4858f79 (diff) | |
download | cpython-6c1a4fb6d400827155fd70e48d682e35397731a1.tar.gz cpython-6c1a4fb6d400827155fd70e48d682e35397731a1.zip |
gh-121058: Warn if `PyThreadState_Clear` is called with an exception set (gh-121343)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 01e54fc745d..44f55be5b5b 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -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. |