[Python-checkins] r85946 - python/branches/py3k/Lib/test/test_dbm_dumb.py

brett.cannon python-checkins at python.org
Sat Oct 30 00:49:14 CEST 2010


Author: brett.cannon
Date: Sat Oct 30 00:49:14 2010
New Revision: 85946

Log:
Properly close files in test_dbm_dumb.

Modified:
   python/branches/py3k/Lib/test/test_dbm_dumb.py

Modified: python/branches/py3k/Lib/test/test_dbm_dumb.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dbm_dumb.py	(original)
+++ python/branches/py3k/Lib/test/test_dbm_dumb.py	Sat Oct 30 00:49:14 2010
@@ -132,12 +132,14 @@
         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')


More information about the Python-checkins mailing list