Skip to content

Commit 732bf88

Browse files
committed
fix: avoid changing class outside of GIL
1 parent dff9b3b commit 732bf88

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/pybind11/iostream.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ class pythonbuf : public std::streambuf {
5252

5353
pywrite(line);
5454
pyflush();
55+
56+
// Placed inside gil_scoped_aquire as a mutex to avoid a race
57+
setp(pbase(), epptr());
5558
}
5659

57-
setp(pbase(), epptr());
5860
}
5961
return 0;
6062
}

0 commit comments

Comments
 (0)