diff --git a/pwndbg/color/__init__.py b/pwndbg/color/__init__.py index c2dc12315..e9a31d275 100644 --- a/pwndbg/color/__init__.py +++ b/pwndbg/color/__init__.py @@ -7,6 +7,8 @@ from __future__ import unicode_literals import re +import six + import pwndbg.memoize NORMAL = "\x1b[0m" @@ -72,9 +74,17 @@ def terminateWith(x, color): return re.sub('\x1b\\[0m', NORMAL + color, x) def ljust_colored(x, length, char=' '): + # TODO: workaround until issue #404 + if six.PY2: + x = x if isinstance(x, six.text_type) else x.decode('utf8') + char = char if isinstance(char, six.text_type) else char.decode('utf8') remaining = length - len(strip(x)) return x + ((remaining // len(char) + 1) * char)[:remaining] def rjust_colored(x, length, char=' '): + # TODO: workaround until issue #404 + if six.PY2: + x = x if isinstance(x, six.text_type) else x.decode('utf8') + char = char if isinstance(char, six.text_type) else char.decode('utf8') remaining = length - len(strip(x)) return ((remaining // len(char) + 1) * char)[:remaining] + x