From c0eee315f5ea3efa6143f4b976ad2be80e3f182f Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 29 Oct 2010 22:49:14 +0000 Subject: [PATCH] Properly close files in test_dbm_dumb. --- Lib/test/test_dbm_dumb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py index a05db915e7..6b981c429d 100644 --- a/Lib/test/test_dbm_dumb.py +++ b/Lib/test/test_dbm_dumb.py @@ -132,12 +132,14 @@ class DumbDBMTestCase(unittest.TestCase): f.close() # Mangle the file by changing the line separator to Windows or Unix - data = io.open(_fname + '.dir', 'rb').read() + with io.open(_fname + '.dir', 'rb') as file: + data = file.read() if os.linesep == '\n': data = data.replace(b'\n', b'\r\n') else: data = data.replace(b'\r\n', b'\n') - io.open(_fname + '.dir', 'wb').write(data) + with io.open(_fname + '.dir', 'wb') as file: + file.write(data) f = dumbdbm.open(_fname) self.assertEqual(f[b'1'], b'hello') -- 2.40.0