diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index 9119270e..72baef8f 100644 --- a/include/pybind11/iostream.h +++ b/include/pybind11/iostream.h @@ -43,8 +43,11 @@ private: // This subtraction cannot be negative, so dropping the sign str line(pbase(), static_cast(pptr() - pbase())); - pywrite(line); - pyflush(); + { + gil_scoped_acquire tmp; + pywrite(line); + pyflush(); + } setp(pbase(), epptr()); }