Skip to content

Commit 211087d

Browse files
committed
gh-155504: Set interpreter before thread state initialization
1 parent 3444ef9 commit 211087d

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a crash when thread state creation fails before the thread state is fully
2+
initialized.

Python/pystate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,8 @@ alloc_threadstate(PyInterpreterState *interp)
15081508
}
15091509
reset_threadstate(tstate);
15101510
}
1511+
// Set the interpreter before any later initialization can fail.
1512+
tstate->base.interp = interp;
15111513
return tstate;
15121514
}
15131515

0 commit comments

Comments
 (0)