From 96fd54eaec700cc50e5960f45ee79bc25c2c48c5 Mon Sep 17 00:00:00 2001 From: "R. David Murray" Date: Fri, 8 Oct 2010 15:55:28 +0000 Subject: #4661: add bytes parsing and generation to email (email version bump to 5.1.0) The work on this is not 100% complete, but everything is present to allow real-world testing of the code. The only remaining major todo item is to (hopefully!) enhance the handling of non-ASCII bytes in headers converted to unicode by RFC2047 encoding them rather than replacing them with '?'s. --- Lib/email/feedparser.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/email/feedparser.py') diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py index 8db70b3c36..de8750dc16 100644 --- a/Lib/email/feedparser.py +++ b/Lib/email/feedparser.py @@ -482,3 +482,10 @@ class FeedParser: if lastheader: # XXX reconsider the joining of folded lines self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip('\r\n') + + +class BytesFeedParser(FeedParser): + """Like FeedParser, but feed accepts bytes.""" + + def feed(self, data): + super().feed(data.decode('ascii', 'surrogateescape')) -- cgit v1.2.1