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.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/email/parser.py b/Lib/email/parser.py
index 9f5f95d..8c9bc9e 100644
--- a/Lib/email/parser.py
+++ b/Lib/email/parser.py
@@ -106,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):