except TypeError instead of UnicodeDecodeError

This commit is contained in:
RedBug312 2017-07-16 13:18:06 +08:00 committed by Casper da Costa-Luis
parent a6c4ce4ee0
commit 825f7dc7ea
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 1 additions and 1 deletions

View File

@ -293,6 +293,6 @@ def _text_width(s): # pragma: no cover
else:
try:
return len(s) + sum(east_asian_width(ch) in 'FW' for ch in s)
except UnicodeDecodeError: # Py2
except TypeError: # Py2
s = s.decode('utf-8')
return len(s) + sum(east_asian_width(ch) in 'FW' for ch in s)