From: Brett Cannon Date: Fri, 29 Oct 2010 23:08:13 +0000 (+0000) Subject: Properly close a temporary TextIOWrapper in 'email'. X-Git-Tag: v3.2a4~280 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06407b35b16cdd141a1cc6fdc122762add855279;p=thirdparty%2FPython%2Fcpython.git Properly close a temporary TextIOWrapper in 'email'. --- diff --git a/Lib/email/parser.py b/Lib/email/parser.py index b83e0f7e6b54..6caaff53ad40 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):