From 732bf88d19989f5927b0a58e0b3fe0e897d2503c Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Tue, 26 Jan 2021 19:29:22 -0500 Subject: [PATCH] fix: avoid changing class outside of GIL --- include/pybind11/iostream.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index 7f34bb20..9dee7554 100644 --- a/include/pybind11/iostream.h +++ b/include/pybind11/iostream.h @@ -52,9 +52,11 @@ private: pywrite(line); pyflush(); + + // Placed inside gil_scoped_aquire as a mutex to avoid a race + setp(pbase(), epptr()); } - setp(pbase(), epptr()); } return 0; }