From 0a21d270046f97a8d7da4378ca3a54b4a7f898b8 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Sat, 9 Jul 2016 12:43:21 +0530 Subject: strutils.hexdump returns native_strings --- netlib/strutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'netlib/strutils.py') diff --git a/netlib/strutils.py b/netlib/strutils.py index 9208f954..a51df886 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -146,7 +146,7 @@ def hexdump(s): A generator of (offset, hex, str) tuples """ for i in range(0, len(s), 16): - offset = "{:0=10x}".format(i).encode() + offset = "{:0=10x}".format(i) part = s[i:i + 16] x = " ".join("{:0=2x}".format(i) for i in six.iterbytes(part)) x = x.ljust(47) # 16*2 + 15 -- cgit v1.2.3 From 83a1cc5a9a62dbe22bd9e87f496928ae1664da2b Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Sat, 9 Jul 2016 12:57:55 +0530 Subject: Make escape_control_characters handle strings on Py2 --- netlib/strutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'netlib/strutils.py') diff --git a/netlib/strutils.py b/netlib/strutils.py index a51df886..32e77927 100644 --- a/netlib/strutils.py +++ b/netlib/strutils.py @@ -57,8 +57,8 @@ def escape_control_characters(text, keep_spacing=True): Args: keep_spacing: If True, tabs and newlines will not be replaced. """ - # type: (six.text_type) -> six.text_type - if not isinstance(text, six.text_type): + # type: (six.string_types) -> six.text_type + if not isinstance(text, six.string_types): raise ValueError("text type must be unicode but is {}".format(type(text).__name__)) trans = _control_char_trans_newline if keep_spacing else _control_char_trans -- cgit v1.2.3