issue #477: polyfill partition() use in mitogen.ssh.

This commit is contained in:
David Wilson 2019-01-23 12:44:08 +00:00
parent a48ee3a536
commit d6da84c38f
1 changed files with 3 additions and 2 deletions

View File

@ -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'