From: Jeremy Stanley Date: Wed, 16 Oct 2013 01:26:22 +0000 (+0000) Subject: Recast to unicode when normalizing on Python 2.x X-Git-Tag: 0.0.1~261 X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=d92cf2f5ca5d8c4c0cd57d2a8bd0920d6ad22382;p=mudpy.git Recast to unicode when normalizing on Python 2.x * lib/mudpy/misc.py: Explicitly recast text to unicode type when passing to unicodedata.normalize on Python 2.x. --- diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index b39610b..d8c863a 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -1202,7 +1202,11 @@ def wrap_ansi_text(text, width): escape = False # normalize any potentially composited unicode before we count it - text = unicodedata.normalize("NFKC", text) + # TODO: remove this check after the switch to py3k + try: + text = unicodedata.normalize("NFKC", text) + except TypeError: + text = unicodedata.normalize("NFKC", unicode(text)) # iterate over each character from the begining of the text for each_character in text: