[cwconfig] Explicitly close generated config file
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 25 Nov 2015 16:22:42 +0100
changeset 10931 6168a45f62df
parent 10930 e0f5bfafec90
child 10932 cb217b2b3463
[cwconfig] Explicitly close generated config file
cwconfig.py
--- a/cwconfig.py	Wed Nov 25 17:57:07 2015 +0100
+++ b/cwconfig.py	Wed Nov 25 16:22:42 2015 +0100
@@ -1059,7 +1059,8 @@
 
     def save(self):
         """write down current configuration"""
-        self.generate_config(open(self.main_config_file(), 'w'))
+        with open(self.main_config_file(), 'w') as fobj:
+            self.generate_config(fobj)
 
     def check_writeable_uid_directory(self, path):
         """check given directory path exists, belongs to the user running the