1. Kang Zhang
  2. Python Keyring Lib

Commits

Jason R. Coombs  committed efbe12d

Ensure file is closed

  • Participants
  • Parent commits 7f5f9fd
  • Branches default

Comments (0)

Files changed (1)

File keyring/backend.py

View file
             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"""