Skip to content

Commit ff9c572

Browse files
committed
Fix iostream when used with nogil
1 parent 060936f commit ff9c572

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
@@ -42,8 +42,11 @@ class pythonbuf : public std::streambuf {
4242
// This subtraction cannot be negative, so dropping the sign
4343
str line(pbase(), static_cast<size_t>(pptr() - pbase()));
4444

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

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

0 commit comments

Comments
 (0)