gh-126016: Remove bad assertion in `PyThreadState_Clear` (GH-139158) · python/cpython@9243a4b · GitHub
Skip to content

Commit 9243a4b

Browse files
gh-126016: Remove bad assertion in PyThreadState_Clear (GH-139158)
In the _interpreters module, we use PyEval_EvalCode() to run Python code in another interpreter. However, when the process receives a KeyboardInterrupt, PyEval_EvalCode() will jump straight to finalization rather than returning. This prevents us from cleaning up and marking the thread as "not running main", which triggers an assertion in PyThreadState_Clear() on debug builds. Since everything else works as intended, remove that assertion.
1 parent e3d9bd6 commit 9243a4b

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

Lib/test/test_interpreters/test_api.py

Lines changed: 27 additions & 1 deletion
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix an assertion failure when sending :exc:`KeyboardInterrupt` to a Python
2+
process running a subinterpreter in a separate thread.

Python/pystate.c

Lines changed: 5 additions & 1 deletion

0 commit comments

Comments
 (0)