mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Fix #10258 - clean up resource warning
This commit is contained in:
parent
810921b675
commit
9f5f65c736
1 changed files with 4 additions and 2 deletions
|
@ -590,8 +590,10 @@ def roundtrip(f):
|
||||||
"""
|
"""
|
||||||
if isinstance(f, str):
|
if isinstance(f, str):
|
||||||
f = BytesIO(f.encode('utf-8'))
|
f = BytesIO(f.encode('utf-8'))
|
||||||
token_list = list(tokenize(f.readline))
|
try:
|
||||||
f.close()
|
token_list = list(tokenize(f.readline))
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
tokens1 = [tok[:2] for tok in token_list]
|
tokens1 = [tok[:2] for tok in token_list]
|
||||||
new_bytes = untokenize(tokens1)
|
new_bytes = untokenize(tokens1)
|
||||||
readline = (line for line in new_bytes.splitlines(1)).__next__
|
readline = (line for line in new_bytes.splitlines(1)).__next__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue