]> granicus.if.org Git - python/commitdiff
Issue #21729: Used the "with" statement in the dbm.dumb module to ensure
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 25 Jun 2014 17:37:30 +0000 (20:37 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 25 Jun 2014 17:37:30 +0000 (20:37 +0300)
files closing.  Patch by Claudiu Popa.

1  2 
Lib/dbm/dumb.py
Misc/NEWS

diff --cc Lib/dbm/dumb.py
index 75de29ad9e94a3cfb0c8a60aacf50ff9a6a4956a,8f48aadade83ba0ceebdd3574e924e4fe213d010..f95ab85f4a21a6eae74ad724d764290e4402a68f
@@@ -79,9 -68,11 +79,10 @@@ class _Database(collections.MutableMapp
          try:
              f = _io.open(self._datfile, 'r', encoding="Latin-1")
          except OSError:
-             f = _io.open(self._datfile, 'w', encoding="Latin-1")
-             self._chmod(self._datfile)
-         f.close()
+             with _io.open(self._datfile, 'w', encoding="Latin-1") as f:
+                 self._chmod(self._datfile)
+         else:
+             f.close()
 -        self._update()
  
      # Read directory file into the in-memory index dict.
      def _update(self):
diff --cc Misc/NEWS
index 416b46b4817c70683a8e3ede1ba05c3e64f59b12,487799c917fd2f05bc73ff999324b13bb88daf44..9ae200a61e674a82f31fd8ed09edefb3673e0a25
+++ b/Misc/NEWS
@@@ -103,12 -27,23 +103,15 @@@ Core and Builtin
  Library
  -------
  
+ - Issue #21729: Used the "with" statement in the dbm.dumb module to ensure
+   files closing.  Patch by Claudiu Popa.
  - Issue #21491: socketserver: Fix a race condition in child processes reaping.
  
 -- Issue #21832:  Require named tuple inputs to be exact strings.
 -
 -- Issue #19145:  The times argument for itertools.repeat now handles
 -  negative values the same way for keyword arguments as it does for
 -  positional arguments.
 +- Issue #21719: Added the ``st_file_attributes`` field to os.stat_result on
 +  Windows.
  
 -- Issue #21812: turtle.shapetransform did not tranform the turtle on the
 -  first call.  (Issue identified and fixed by Lita Cho.)
 -
 -- Issue #21635:  The difflib SequenceMatcher.get_matching_blocks() method
 -  cache didn't match the actual result.  The former was a list of tuples
 -  and the latter was a list of named tuples.
 +- Issue #21832:  Require named tuple inputs to be exact strings.
  
  - Issue #21722: The distutils "upload" command now exits with a non-zero
    return code when uploading fails.  Patch by Martin Dengler.