diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index 7f34bb201..9dee75543 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; }