Mercurial > cpython-lru_cache-weakref
diff Lib/email/parser.py @ 69334:a95d936ce8eb
#11684: Complete parser bytes interface by adding BytesHeaderParser
Patch by Steffen Daode Nurpmeso.
| author | R David Murray <rdmurray@bitdance.com> |
|---|---|
| date | Wed, 13 Apr 2011 16:46:05 -0400 |
| parents | 5a71d41ea20a |
| children | 2f3fda9d3906 |
line wrap: on
line diff
--- a/Lib/email/parser.py Wed Apr 13 11:50:34 2011 -0700 +++ b/Lib/email/parser.py Wed Apr 13 16:46:05 2011 -0400 @@ -4,7 +4,7 @@ """A parser of RFC 2822 and MIME email messages.""" -__all__ = ['Parser', 'HeaderParser'] +__all__ = ['Parser', 'HeaderParser', 'BytesParser', 'BytesHeaderParser'] import warnings from io import StringIO, TextIOWrapper @@ -114,3 +114,11 @@ """ text = text.decode('ASCII', errors='surrogateescape') return self.parser.parsestr(text, headersonly) + + +class BytesHeaderParser(BytesParser): + def parse(self, fp, headersonly=True): + return BytesParser.parse(self, fp, headersonly=True) + + def parsebytes(self, text, headersonly=True): + return BytesParser.parsebytes(self, text, headersonly=True)
