From: Serhiy Storchaka Date: Wed, 25 Jun 2014 17:37:30 +0000 (+0300) Subject: Issue #21729: Used the "with" statement in the dbm.dumb module to ensure X-Git-Tag: v3.5.0a1~1409 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5243cc7134b4bc16c91e225ce9d860cc1a4d6f7;p=python Issue #21729: Used the "with" statement in the dbm.dumb module to ensure files closing. Patch by Claudiu Popa. --- e5243cc7134b4bc16c91e225ce9d860cc1a4d6f7 diff --cc Lib/dbm/dumb.py index 75de29ad9e,8f48aadade..f95ab85f4a --- a/Lib/dbm/dumb.py +++ b/Lib/dbm/dumb.py @@@ -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 416b46b481,487799c917..9ae200a61e --- a/Misc/NEWS +++ 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.