summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tokenize.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-10-30 21:35:28 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-10-30 21:35:28 (GMT)
commit9f5f65c736745cfd11efee0418dfb98d1ddec93d (patch)
tree52763884349e6a3958bb3ef68978adedd26b6298 /Lib/test/test_tokenize.py
parent810921b675654fc6560747390eb657fa765d46ba (diff)
downloadcpython-9f5f65c736745cfd11efee0418dfb98d1ddec93d.zip
cpython-9f5f65c736745cfd11efee0418dfb98d1ddec93d.tar.gz
cpython-9f5f65c736745cfd11efee0418dfb98d1ddec93d.tar.bz2
Fix #10258 - clean up resource warning
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r--Lib/test/test_tokenize.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 3f45d9c..10e59b9 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -590,8 +590,10 @@ def roundtrip(f):
"""
if isinstance(f, str):
f = BytesIO(f.encode('utf-8'))
- token_list = list(tokenize(f.readline))
- f.close()
+ try:
+ token_list = list(tokenize(f.readline))
+ finally:
+ f.close()
tokens1 = [tok[:2] for tok in token_list]
new_bytes = untokenize(tokens1)
readline = (line for line in new_bytes.splitlines(1)).__next__