From d92cf2f5ca5d8c4c0cd57d2a8bd0920d6ad22382 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 16 Oct 2013 01:26:22 +0000 Subject: [PATCH] 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. --- lib/mudpy/misc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: -- 2.11.0