[devtools] fix ResourceWarning: unclosed file tmpdb-__default_empty_db__.config
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 19 Oct 2015 17:54:26 +0200
changeset 10819 5b5864483c4d
parent 10818 8cdf9965b2b8
child 10820 fef0ab4c4f94
[devtools] fix ResourceWarning: unclosed file tmpdb-__default_empty_db__.config
devtools/__init__.py
--- a/devtools/__init__.py	Mon Oct 19 17:53:51 2015 +0200
+++ b/devtools/__init__.py	Mon Oct 19 17:54:26 2015 +0200
@@ -370,7 +370,8 @@
         # XXX set a clearer error message ???
         backup_coordinates, config_path = self.db_cache[self.db_cache_key(db_id)]
         # reload the config used to create the database.
-        config = pickle.loads(open(config_path, 'rb').read())
+        with open(config_path, 'rb') as f:
+            config = pickle.load(f)
         # shutdown repo before changing database content
         if self._repo is not None:
             self._repo.turn_repo_off()