From fa7246279817b7c01448fd4059c8d2be34e84f8b Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 1 Jul 2016 17:17:16 -0700 Subject: fix tcp message handling --- netlib/strutils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'netlib/strutils.py') diff --git a/netlib/strutils.py b/netlib/strutils.py index ca6eaa42..414b2e57 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -29,6 +29,7 @@ def native(s, *encoding_opts): def clean_bin(s, keep_spacing=True): + # type: (Union[bytes, six.text_type], bool) -> six.text_type """ Cleans binary data to make it safe to display. @@ -49,8 +50,8 @@ def clean_bin(s, keep_spacing=True): keep = (9, 10, 13) # \t, \n, \r, else: keep = () - return b"".join( - six.int2byte(ch) if (31 < ch < 127 or ch in keep) else b"." + return "".join( + chr(ch) if (31 < ch < 127 or ch in keep) else "." for ch in six.iterbytes(s) ) @@ -133,6 +134,6 @@ def hexdump(s): for i in range(0, len(s), 16): offset = "{:0=10x}".format(i).encode() part = s[i:i + 16] - x = b" ".join("{:0=2x}".format(i).encode() for i in six.iterbytes(part)) + x = " ".join("{:0=2x}".format(i) for i in six.iterbytes(part)) x = x.ljust(47) # 16*2 + 15 yield (offset, x, clean_bin(part, False)) -- cgit v1.2.3