* [gentoo-commits] gentoo-x86 commit in dev-python/feedparser/files: feedparser-5.1.3-backport_fix_for_chardet-py3.patch
@ 2014-02-24 9:05 Justin Lecher (jlec)
0 siblings, 0 replies; only message in thread
From: Justin Lecher (jlec) @ 2014-02-24 9:05 UTC (permalink / raw
To: gentoo-commits
jlec 14/02/24 09:05:50
Added: feedparser-5.1.3-backport_fix_for_chardet-py3.patch
Log:
dev-python/feedparser: Backport fix for py3.3 support
(Portage version: 2.2.8-r1/cvs/Linux x86_64, signed Manifest commit with key B9D4F231BD1558AB!)
Revision Changes Path
1.1 dev-python/feedparser/files/feedparser-5.1.3-backport_fix_for_chardet-py3.patch
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/feedparser/files/feedparser-5.1.3-backport_fix_for_chardet-py3.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/feedparser/files/feedparser-5.1.3-backport_fix_for_chardet-py3.patch?rev=1.1&content-type=text/plain
Index: feedparser-5.1.3-backport_fix_for_chardet-py3.patch
===================================================================
From 20a32910f4a521788ba93a8c809cf0db702bed5b Mon Sep 17 00:00:00 2001
From: Kurt McKee <contactme@kurtmckee.org>
Date: Mon, 17 Dec 2012 10:41:13 -0600
Subject: [PATCH] Fix chardet support in Python 3
Fixes issue 384.
Thanks to Google user Arfrever.TFA for reporting this!
---
NEWS | 1 +
feedparser/feedparser.py | 6 +++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/feedparser/feedparser.py b/feedparser/feedparser.py
index c78e6a3..e977ae8 100644
--- a/feedparser/feedparser.py
+++ b/feedparser/feedparser.py
@@ -3766,7 +3766,11 @@ def convert_to_utf8(http_headers, data):
chardet_encoding = None
tried_encodings = []
if chardet:
- chardet_encoding = unicode(chardet.detect(data)['encoding'] or '', 'ascii', 'ignore')
+ chardet_encoding = chardet.detect(data)['encoding']
+ if not chardet_encoding:
+ chardet_encoding = ''
+ if not isinstance(chardet_encoding, unicode):
+ chardet_encoding = unicode(chardet_encoding, 'ascii', 'ignore')
# try: HTTP encoding, declared XML encoding, encoding sniffed from BOM
for proposed_encoding in (rfc3023_encoding, xml_encoding, bom_encoding,
chardet_encoding, u'utf-8', u'windows-1252', u'iso-8859-2'):
--
1.8.5.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-24 9:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-24 9:05 [gentoo-commits] gentoo-x86 commit in dev-python/feedparser/files: feedparser-5.1.3-backport_fix_for_chardet-py3.patch Justin Lecher (jlec)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox