mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#21476: Unwrap fp in BytesParser so the file isn't unexpectedly closed.
This makes the behavior match that of Parser. Patch by Vajrasky Kok.
This commit is contained in:
parent
19454563d8
commit
c6772c4d59
3 changed files with 31 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue