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

issue510
David Wilson 7 years ago
parent a48ee3a536
commit d6da84c38f

@ -40,6 +40,7 @@ except ImportError:
import mitogen.parent import mitogen.parent
from mitogen.core import b from mitogen.core import b
from mitogen.core import bytes_partition
LOG = logging.getLogger('mitogen') LOG = logging.getLogger('mitogen')
@ -98,12 +99,12 @@ def filter_debug(stream, it):
elif state == 'in_debug': elif state == 'in_debug':
if b('\n') not in buf: if b('\n') not in buf:
break break
line, _, buf = buf.partition(b('\n')) line, _, buf = bytes_partition(buf, b('\n'))
LOG.debug('%r: %s', stream, LOG.debug('%r: %s', stream,
mitogen.core.to_text(line.rstrip())) mitogen.core.to_text(line.rstrip()))
state = 'start_of_line' state = 'start_of_line'
elif state == 'in_plain': 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) yield line + nl, not (nl or buf)
if nl: if nl:
state = 'start_of_line' state = 'start_of_line'

Loading…
Cancel
Save