fix detail::pythonbuf::overflow()'s return value to return not_eof(c) (#1479)

This commit is contained in:
Justin Bassett 2018-08-29 02:48:30 -07:00 committed by Wenzel Jakob
parent d0c1d286cb
commit b47192f069
2 changed files with 11 additions and 1 deletions

View File

@ -34,7 +34,7 @@ private:
*pptr() = traits_type::to_char_type(c); *pptr() = traits_type::to_char_type(c);
pbump(1); pbump(1);
} }
return sync() ? traits_type::not_eof(c) : traits_type::eof(); return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof();
} }
int sync() { int sync() {

View File

@ -53,6 +53,16 @@ def test_captured(capsys):
assert stdout == '' assert stdout == ''
assert stderr == msg assert stderr == msg
def test_captured_large_string(capsys):
# Make this bigger than the buffer used on the C++ side: 1024 chars
msg = "I've been redirected to Python, I hope!"
msg = msg * (1024 // len(msg) + 1)
m.captured_output_default(msg)
stdout, stderr = capsys.readouterr()
assert stdout == msg
assert stderr == ''
def test_guard_capture(capsys): def test_guard_capture(capsys):
msg = "I've been redirected to Python, I hope!" msg = "I've been redirected to Python, I hope!"