More proper closing of files

This commit is contained in:
Antoine Pitrou 2010-10-14 22:11:44 +00:00
parent 73315e9200
commit 92f60ed82a
7 changed files with 82 additions and 57 deletions

View file

@ -48,8 +48,8 @@ class Test_MultibyteCodec(unittest.TestCase):
def test_codingspec(self):
try:
for enc in ALL_CJKENCODINGS:
print('# coding:', enc, file=io.open(TESTFN, 'w'))
exec(open(TESTFN).read())
code = '# coding: {}\n'.format(enc)
exec(code)
finally:
support.unlink(TESTFN)