File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 11FormatStyle : file
22
33Checks : '
4- -*,
54llvm-namespace-comment,
65modernize-use-override,
76readability-container-size-empty,
Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ class pythonbuf : public std::streambuf {
3838 return sync () == 0 ? traits_type::not_eof (c) : traits_type::eof ();
3939 }
4040
41- int sync () override {
41+ // This function must be non-virtual to be called in a destructor
42+ int _sync () {
4243 if (pbase () != pptr ()) {
4344 // This subtraction cannot be negative, so dropping the sign
4445 str line (pbase (), static_cast <size_t >(pptr () - pbase ()));
@@ -54,6 +55,10 @@ class pythonbuf : public std::streambuf {
5455 return 0 ;
5556 }
5657
58+ int sync () override {
59+ return _sync ();
60+ }
61+
5762public:
5863
5964 pythonbuf (object pyostream, size_t buffer_size = 1024 )
@@ -68,7 +73,7 @@ class pythonbuf : public std::streambuf {
6873
6974 // / Sync before destroy
7075 ~pythonbuf () override {
71- sync ();
76+ _sync ();
7277 }
7378};
7479
You can’t perform that action at this time.
0 commit comments