From e3f525ff2ad1ae52337cf2995edd69992430c481 Mon Sep 17 00:00:00 2001 From: pictuga Date: Wed, 4 Dec 2013 20:26:39 +0100 Subject: [PATCH] Fix JSON related encoding issue --- feeds.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/feeds.py b/feeds.py index 4f936a3..be7d5af 100644 --- a/feeds.py +++ b/feeds.py @@ -51,7 +51,9 @@ def parse(data): match = re.search('encoding=["\']?([0-9a-zA-Z-]+)', data[:100]) if match: enc = match.groups()[0].lower() - data = data.decode(enc, 'ignore').encode(enc) + if not isinstance(data, unicode): + data = data.decode(enc, 'ignore') + data = data.encode(enc) # parse parser = etree.XMLParser(recover=True)