Commits

Jason R. Coombs committed efbe12d

Ensure file is closed

Comments (0)

Files changed (1)

keyring/backend.py

             config.add_section(service)
         config.set(service, username, password_base64)
         self._ensure_file_path()
-        config_file = open(self.file_path,'w')
-        config.write(config_file)
+        config_file = open(self.file_path, 'w')
+        try:
+            config.write(config_file)
+        finally:
+            config_file.close()
 
     def _ensure_file_path(self):
         """ensure the storage path exists"""