Skip to content

Commit aebf437

Browse files
committed
fixup! style: clang-tidy: default checks and fix bug in iostream deconstruction
1 parent 00e4bf2 commit aebf437

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

include/pybind11/iostream.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class pythonbuf : public std::streambuf {
3838
return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof();
3939
}
4040

41-
// This function must be non-virtual to be called in a destructor
42-
int _sync() {
41+
int sync() override {
4342
if (pbase() != pptr()) {
4443
// This subtraction cannot be negative, so dropping the sign
4544
str line(pbase(), static_cast<size_t>(pptr() - pbase()));
@@ -55,10 +54,6 @@ class pythonbuf : public std::streambuf {
5554
return 0;
5655
}
5756

58-
int sync() override {
59-
return _sync();
60-
}
61-
6257
public:
6358

6459
pythonbuf(object pyostream, size_t buffer_size = 1024)
@@ -73,7 +68,9 @@ class pythonbuf : public std::streambuf {
7368

7469
/// Sync before destroy
7570
~pythonbuf() override {
76-
_sync();
71+
// Must be fully qualified, since the vtable for the base is loaded
72+
// here, not the child.
73+
pythonbuf::sync();
7774
}
7875
};
7976

0 commit comments

Comments
 (0)