From 45a91d828f948b56e416203253527b96863a0daf Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Fri, 30 Apr 2021 00:43:49 +0200 Subject: [PATCH] Remove trailing whitespace and formatting iostream --- include/pybind11/iostream.h | 6 +++--- tests/test_iostream.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h index b3d6e78273..94d2ff2b73 100644 --- a/include/pybind11/iostream.h +++ b/include/pybind11/iostream.h @@ -41,7 +41,7 @@ class pythonbuf : public std::streambuf { return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof(); } - // Computes how many bytes at the end of the buffer are part of an + // Computes how many bytes at the end of the buffer are part of an // incomplete sequence of UTF-8 bytes. // Precondition: pbase() < pptr() size_t utf8_remainder() const { @@ -71,7 +71,7 @@ class pythonbuf : public std::streambuf { const auto dist = static_cast(leading - rpptr); size_t remainder = 0; - if (dist == 0) + if (dist == 0) remainder = 1; // 1-byte code point is impossible else if (dist == 1) remainder = is_leading_2b(*leading) ? 0 : dist + 1; @@ -79,7 +79,7 @@ class pythonbuf : public std::streambuf { remainder = is_leading_3b(*leading) ? 0 : dist + 1; // else if (dist >= 3), at least 4 bytes before encountering an UTF-8 // leading byte, either no remainder or invalid UTF-8. - // Invalid UTF-8 will cause an exception later when converting + // Invalid UTF-8 will cause an exception later when converting // to a Python string, so that's not handled here. return remainder; } diff --git a/tests/test_iostream.py b/tests/test_iostream.py index 213569a8d3..e2b74d01cb 100644 --- a/tests/test_iostream.py +++ b/tests/test_iostream.py @@ -68,6 +68,7 @@ def test_captured_large_string(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_2byte_offset0(capsys): msg = "\u07FF" msg = "" + msg * (1024 // len(msg) + 1) @@ -77,6 +78,7 @@ def test_captured_utf8_2byte_offset0(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_2byte_offset1(capsys): msg = "\u07FF" msg = "1" + msg * (1024 // len(msg) + 1) @@ -86,6 +88,7 @@ def test_captured_utf8_2byte_offset1(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_3byte_offset0(capsys): msg = "\uFFFF" msg = "" + msg * (1024 // len(msg) + 1) @@ -95,6 +98,7 @@ def test_captured_utf8_3byte_offset0(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_3byte_offset1(capsys): msg = "\uFFFF" msg = "1" + msg * (1024 // len(msg) + 1) @@ -104,6 +108,7 @@ def test_captured_utf8_3byte_offset1(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_3byte_offset2(capsys): msg = "\uFFFF" msg = "12" + msg * (1024 // len(msg) + 1) @@ -113,6 +118,7 @@ def test_captured_utf8_3byte_offset2(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_4byte_offset0(capsys): msg = "\U0010FFFF" msg = "" + msg * (1024 // len(msg) + 1) @@ -122,6 +128,7 @@ def test_captured_utf8_4byte_offset0(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_4byte_offset1(capsys): msg = "\U0010FFFF" msg = "1" + msg * (1024 // len(msg) + 1) @@ -131,6 +138,7 @@ def test_captured_utf8_4byte_offset1(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_4byte_offset2(capsys): msg = "\U0010FFFF" msg = "12" + msg * (1024 // len(msg) + 1) @@ -140,6 +148,7 @@ def test_captured_utf8_4byte_offset2(capsys): assert stdout == msg assert stderr == "" + def test_captured_utf8_4byte_offset3(capsys): msg = "\U0010FFFF" msg = "123" + msg * (1024 // len(msg) + 1) @@ -149,6 +158,7 @@ def test_captured_utf8_4byte_offset3(capsys): assert stdout == msg assert stderr == "" + def test_guard_capture(capsys): msg = "I've been redirected to Python, I hope!" m.guard_output(msg)