Commits

Jason R. Coombs committed 9c1bb8a

Include an error message when the password cannot be sent. Fixes #46.

  • Participants
  • Parent commits 81da1da

Comments (0)

Files changed (1)

File keyring/backend.py

     def set_password(self, service, username, password):
         """Set password for the username of the service
         """
-        raise PasswordSetError()
+        raise PasswordSetError("reason")
 
 class _ExtensionKeyring(KeyringBackend):
     """_ExtensionKeyring is a adaptor class for the platform related keyring
         """
         try:
             self.keyring_impl.password_set(service, username, password)
-        except OSError:
-            raise PasswordSetError()
+        except OSError, e:
+            raise PasswordSetError(e.message)
 
 class OSXKeychain(_ExtensionKeyring):
     """Mac OSX Keychain"""
                 None, None, None, None, 0, password)
         except gnomekeyring.CancelledError:
             # The user pressed "Cancel" when prompted to unlock their keyring.
-            raise PasswordSetError()
+            raise PasswordSetError("cancelled by user")
 
 kwallet = None
 
             self.pywintypes = pywintypes
         except ImportError:
             self.win32cred = None
-    
+
     def supported(self):
         '''Default Windows backend, when it is available
         '''
             return 1
         else:
             return 0
-    
+
     def get_password(self, service, username):
         try:
-            blob = self.win32cred.CredRead(Type=self.win32cred.CRED_TYPE_GENERIC, 
+            blob = self.win32cred.CredRead(Type=self.win32cred.CRED_TYPE_GENERIC,
                                            TargetName=service)['CredentialBlob']
         except self.pywintypes.error, e:
             if e[:2] == (1168, 'CredRead'):
                 return None
             raise
         return blob.decode("utf16")
-    
+
     def set_password(self, service, username, password):
-        credential = dict(Type=self.win32cred.CRED_TYPE_GENERIC, 
+        credential = dict(Type=self.win32cred.CRED_TYPE_GENERIC,
                           TargetName=service,
                           UserName=username,
                           CredentialBlob=unicode(password),