diff --git a/pythonforandroid/logger.py b/pythonforandroid/logger.py index d3ab179ef9..1f8871fdd7 100644 --- a/pythonforandroid/logger.py +++ b/pythonforandroid/logger.py @@ -92,8 +92,12 @@ def shorten_string(string, max_width): return string visible = max_width - 16 - int(log10(string_len)) # expected suffix len "...(and XXXXX more)" - return u''.join((string[:visible], u'...(and ', str(string_len - visible), - u' more)')) + if not isinstance(string, unistr): + visstring = unistr(string[:visible], errors='ignore') + else: + visstring = string[:visible] + return u''.join((visstring, u'...(and ', + unistr(string_len - visible), u' more)')) def get_console_width(): @@ -204,3 +208,6 @@ def printtail(out, name, forecolor, tail_n=0, raise return output + + +from pythonforandroid.util import unistr diff --git a/pythonforandroid/util.py b/pythonforandroid/util.py index a2218c9c27..400bd28092 100644 --- a/pythonforandroid/util.py +++ b/pythonforandroid/util.py @@ -15,6 +15,11 @@ IS_PY3 = sys.version_info[0] >= 3 +if IS_PY3: + unistr = str +else: + unistr = unicode + class ChromeDownloader(FancyURLopener): version = (