From: Adam Sampson Date: Sat, 21 Feb 2009 18:36:38 +0000 (+0000) Subject: Don't encode and decode when copying nearly-unicode objects. X-Git-Tag: v2.13~9 X-Git-Url: http://git.ozo.com/?a=commitdiff_plain;h=3b8eb1c09f63d05d28e95890527d1b928d31c262;p=rawdog%2F.git Don't encode and decode when copying nearly-unicode objects. Why? Because BeautifulSoup's string class has a broken encode implementation... and it appears that the unicode class is smart enough to not reuse the object when it's a subclass anyway. --- diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 0880cf5..988aacd 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -290,7 +290,7 @@ def ensure_unicode(value, encoding): # This is a subclass of unicode (e.g. BeautifulSoup's # NavigableString, which is unpickleable in some versions of # the library), so force it to be a real unicode object. - return value.encode("UTF-8").decode("UTF-8") + return unicode(value) elif isinstance(value, dict): d = {} for (k, v) in value.items():