Skip to content

Commit

Permalink
Fix a bug in writes to the BytesIO C++ wrapper (#71)
Browse files Browse the repository at this point in the history
'\0' bytes were being dropped due to being misinterpreted as string terminators.
Related to #47.
  • Loading branch information
valgur authored Dec 23, 2021
1 parent 2f7d9da commit 787d6cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pystreambuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ class streambuf : public std::basic_streambuf<char>
py::bytes chunk(pbase(), n_written);
py_write(chunk);
if (!traits_type::eq_int_type(c, traits_type::eof())) {
char cs[2] = {traits_type::to_char_type(c)};
py_write(py::bytes(cs));
char cs = traits_type::to_char_type(c);
py_write(py::bytes(&cs, 1));
n_written++;
}
if (n_written) {
Expand Down

0 comments on commit 787d6cb

Please sign in to comment.