Skip to content

Commit 1594396

Browse files
fix dangling thread state issue (#5870)
* fix dangling thread state issue * formatting rules * use tstate .set(nullptr) to pass clang-tidy check * fix spelling mistake * improve comments for maintainability
1 parent 1e5bc66 commit 1594396

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/pybind11/detail/internals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ struct internals {
286286
internals()
287287
: static_property_type(make_static_property_type()),
288288
default_metaclass(make_default_metaclass()) {
289+
tstate.set(nullptr); // See PR #5870
289290
PyThreadState *cur_tstate = PyThreadState_Get();
290-
tstate = cur_tstate;
291291

292292
istate = cur_tstate->interp;
293293
registered_exception_translators.push_front(&translate_exception);

include/pybind11/subinterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ inline subinterpreter_scoped_activate::subinterpreter_scoped_activate(subinterpr
271271
// make the interpreter active and acquire the GIL
272272
old_tstate_ = PyThreadState_Swap(tstate_);
273273

274-
// save this in internals for scoped_gil calls
274+
// save this in internals for scoped_gil calls (see also: PR #5870)
275275
detail::get_internals().tstate = tstate_;
276276
}
277277

0 commit comments

Comments
 (0)