diff --git a/mitogen/ssh.py b/mitogen/ssh.py index 106dfd56..2bee15c8 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -100,7 +100,8 @@ def filter_debug(stream, it): if b('\n') not in buf: break line, _, buf = buf.partition(b('\n')) - LOG.debug('%r: %s', stream, line.rstrip()) + LOG.debug('%r: %s', stream, + mitogen.core.to_text(line.rstrip())) state = 'start_of_line' elif state == 'in_plain': line, nl, buf = buf.partition(b('\n')) diff --git a/tests/ssh_test.py b/tests/ssh_test.py index 661ff5ed..abb25a58 100644 --- a/tests/ssh_test.py +++ b/tests/ssh_test.py @@ -44,6 +44,21 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase): class SshTest(testlib.DockerMixin, testlib.TestCase): stream_class = mitogen.ssh.Stream + def test_debug_decoding(self): + # ensure filter_debug_logs() decodes the logged string. + capture = testlib.LogCapturer() + capture.start() + try: + context = self.docker_ssh( + username='mitogen__has_sudo', + password='has_sudo_password', + ssh_debug_level=3, + ) + finally: + s = capture.stop() + + self.assertTrue("'): debug1: Reading configuration data" in s) + def test_stream_name(self): context = self.docker_ssh( username='mitogen__has_sudo',