Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06407b3

Browse files
committed
Properly close a temporary TextIOWrapper in 'email'.
1 parent c0eee31 commit 06407b3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/email/parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ def parse(self, fp, headersonly=False):
120120
meaning it parses the entire contents of the file.
121121
"""
122122
fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape')
123-
return self.parser.parse(fp, headersonly)
123+
with fp:
124+
return self.parser.parse(fp, headersonly)
124125

125126

126127
def parsebytes(self, text, headersonly=False):

0 commit comments

Comments
 (0)