From d6da84c38f9fd8a45627625bf86201c9c0f60e46 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 23 Jan 2019 12:44:08 +0000 Subject: [PATCH] issue #477: polyfill partition() use in mitogen.ssh. --- mitogen/ssh.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mitogen/ssh.py b/mitogen/ssh.py index 571e80d8..732f2ffc 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -40,6 +40,7 @@ except ImportError: import mitogen.parent from mitogen.core import b +from mitogen.core import bytes_partition LOG = logging.getLogger('mitogen') @@ -98,12 +99,12 @@ def filter_debug(stream, it): elif state == 'in_debug': if b('\n') not in buf: break - line, _, buf = buf.partition(b('\n')) + line, _, buf = bytes_partition(buf, b('\n')) 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')) + line, nl, buf = bytes_partition(buf, b('\n')) yield line + nl, not (nl or buf) if nl: state = 'start_of_line'