mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
#11684: Complete parser bytes interface by adding BytesHeaderParser
Patch by Steffen Daode Nurpmeso.
This commit is contained in:
parent
f400ab40e4
commit
b35c850a3f
5 changed files with 46 additions and 8 deletions
|
@ -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 @@ class BytesParser:
|
|||
"""
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue