From 047ce8c452087809f5ab10d7a2ea58c8709a8da3 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 11 Jun 2019 16:17:50 -0400 Subject: [PATCH] Fix iostream when used with nogil (#1368) --- include/pybind11/iostream.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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()); }