From 3b8eb1c09f63d05d28e95890527d1b928d31c262 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 21 Feb 2009 18:36:38 +0000 Subject: [PATCH] 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. --- rawdoglib/rawdog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(): -- 2.35.1