]> granicus.if.org Git - python/commitdiff
Fix #10258 - clean up resource warning
authorBrian Curtin <brian.curtin@gmail.com>
Sat, 30 Oct 2010 21:35:28 +0000 (21:35 +0000)
committerBrian Curtin <brian.curtin@gmail.com>
Sat, 30 Oct 2010 21:35:28 +0000 (21:35 +0000)
Lib/test/test_tokenize.py

index 3f45d9c5d883ef5e3d5e50cd97c6f3c29220ed1a..10e59b944255be342b331dc56b38146cecfca404 100644 (file)
@@ -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__