From 4d48913ff47e86c1279f4c7c2c6c358021bdbaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Tue, 1 Sep 2020 17:36:50 +0200 Subject: [PATCH] Fix return type of KWallet get_credential() Docs: get_credential(service, username): Return a credential object stored in the active keyring. This object contains at least username and password attributes for the specified service, where the returned username may be different from the argument. Prior to this commit, get_credential() returned the password as a string, without wrapping the credential into a SimpleCredential object. --- keyring/backends/kwallet.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keyring/backends/kwallet.py b/keyring/backends/kwallet.py index 6326971a..12775706 100644 --- a/keyring/backends/kwallet.py +++ b/keyring/backends/kwallet.py @@ -123,7 +123,8 @@ def get_credential(self, service, username): Otherwise, it will return the first username and password combo that it finds. """ if username is not None: - return self.get_password(service, username) + return super().get_credential(service, username) + if not self.connected(service): # the user pressed "cancel" when prompted to unlock their keyring. raise KeyringLocked("Failed to unlock the keyring!") @@ -134,6 +135,8 @@ def get_credential(self, service, username): ) return SimpleCredential(str(username), str(password)) + return None + def set_password(self, service, username, password): """Set password for the username of the service""" if not self.connected(service):