Skip to content

Commit 047ce8c

Browse files
henryiiiwjakob
authored andcommitted
Fix iostream when used with nogil (#1368)
1 parent 95f750a commit 047ce8c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include/pybind11/iostream.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ class pythonbuf : public std::streambuf {
4343
// This subtraction cannot be negative, so dropping the sign
4444
str line(pbase(), static_cast<size_t>(pptr() - pbase()));
4545

46-
pywrite(line);
47-
pyflush();
46+
{
47+
gil_scoped_acquire tmp;
48+
pywrite(line);
49+
pyflush();
50+
}
4851

4952
setp(pbase(), epptr());
5053
}

0 commit comments

Comments
 (0)