summaryrefslogtreecommitdiffstats
path: root/Lib/email/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/email/parser.py')
-rw-r--r--Lib/email/parser.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/email/parser.py b/Lib/email/parser.py
index 752bf35..8c9bc9e 100644
--- a/Lib/email/parser.py
+++ b/Lib/email/parser.py
@@ -4,19 +4,18 @@
"""A parser of RFC 2822 and MIME email messages."""
-__all__ = ['Parser', 'HeaderParser', 'BytesParser', 'BytesHeaderParser']
+__all__ = ['Parser', 'HeaderParser', 'BytesParser', 'BytesHeaderParser',
+ 'FeedParser', 'BytesFeedParser']
-import warnings
from io import StringIO, TextIOWrapper
from email.feedparser import FeedParser, BytesFeedParser
-from email.message import Message
from email._policybase import compat32
class Parser:
- def __init__(self, _class=Message, *, policy=compat32):
+ def __init__(self, _class=None, *, policy=compat32):
"""Parser of RFC 2822 and MIME email messages.
Creates an in-memory object tree representing the email message, which
@@ -107,8 +106,10 @@ class BytesParser:
meaning it parses the entire contents of the file.
"""
fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape')
- with fp:
+ try:
return self.parser.parse(fp, headersonly)
+ finally:
+ fp.detach()
def parsebytes(self, text, headersonly=False):