From 06407b35b16cdd141a1cc6fdc122762add855279 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 29 Oct 2010 23:08:13 +0000 Subject: [PATCH] Properly close a temporary TextIOWrapper in 'email'. --- Lib/email/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/email/parser.py b/Lib/email/parser.py index b83e0f7e6b..6caaff53ad 100644 --- a/Lib/email/parser.py +++ b/Lib/email/parser.py @@ -120,7 +120,8 @@ class BytesParser: meaning it parses the entire contents of the file. """ fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape') - return self.parser.parse(fp, headersonly) + with fp: + return self.parser.parse(fp, headersonly) def parsebytes(self, text, headersonly=False): -- 2.49.0