From 8b564bc934b8b51734c41192ecb0135c264087cc Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 6 Jul 2016 16:47:32 -0700 Subject: [PATCH] fix pathod log encoding --- netlib/strutils.py | 4 ++-- pathod/log.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/netlib/strutils.py b/netlib/strutils.py index 809f5e17e..59816dba7 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -156,8 +156,8 @@ def hexdump(s): part = s[i:i + 16] x = " ".join("{:0=2x}".format(i) for i in six.iterbytes(part)) x = x.ljust(47) # 16*2 + 15 - part_repr = escape_control_characters( + part_repr = native(escape_control_characters( part.decode("ascii", "replace").replace(u"\ufffd", u"."), False - ) + )) yield (offset, x, part_repr) diff --git a/pathod/log.py b/pathod/log.py index d39496e01..478371010 100644 --- a/pathod/log.py +++ b/pathod/log.py @@ -62,9 +62,15 @@ class LogCtx(object): for line in strutils.hexdump(data): self("\t%s %s %s" % line) else: - data = data.decode("ascii", "replace").replace(u"\ufffd", u".") - for i in strutils.escape_control_characters(data).split(u"\n"): - self(u"\t%s" % i) + data = strutils.native( + strutils.escape_control_characters( + data + .decode("ascii", "replace") + .replace(u"\ufffd", u".") + ) + ) + for i in data.split("\n"): + self("\t%s" % i) def __call__(self, line): self.lines.append(line)