diff --git a/.clang-tidy b/.clang-tidy index a4eab6ad..e29d9298 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,6 @@ FormatStyle: file Checks: ' --*, llvm-namespace-comment, modernize-use-override, readability-container-size-empty, diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index 4b4042b0..48479f2d 100644 --- a/include/pybind11/iostream.h +++ b/include/pybind11/iostream.h @@ -38,7 +38,10 @@ private: return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof(); } - int sync() override { + // This function must be non-virtual to be called in a destructor. If the + // rare MSVC test failure shows up with this version, then this should be + // simplified to a fully qualified call. + int _sync() { if (pbase() != pptr()) { // This subtraction cannot be negative, so dropping the sign str line(pbase(), static_cast(pptr() - pbase())); @@ -54,6 +57,10 @@ private: return 0; } + int sync() override { + return _sync(); + } + public: pythonbuf(object pyostream, size_t buffer_size = 1024) @@ -68,7 +75,7 @@ public: /// Sync before destroy ~pythonbuf() override { - sync(); + _sync(); } };