Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecretService get_credential doesn't return None for missing entry #452

Closed
EpicWink opened this issue Jul 29, 2020 · 2 comments · Fixed by #453
Closed

SecretService get_credential doesn't return None for missing entry #452

EpicWink opened this issue Jul 29, 2020 · 2 comments · Fixed by #453

Comments

@EpicWink
Copy link

EpicWink commented Jul 29, 2020

When calling keyring.get_credential using the SecretService backend, if a username is provided but the corresponding entry doesn't exist in the keyring, a Credential object with the provided username (and no password) is returned, instead of None. This is in contrast to what happens in the default implementation, where None is returns if the entry is not found.

This causes pypa/pip#8634

Reproduction

>>> import keyring
>>> c = keyring.get_credential("spam", "eggs")

Expected

>>> print(c)
None

Actual

>>> print(c)
<keyring.credentials.SimpleCredential object at 0x...>
>>> print(c.username, c.password)
eggs None

Environment

  • OS: Ubuntu 20.04.1
  • keyring: 21.2.1 (first seen in 19.2)
    • keyring.backends.chainer.ChainerBackend (priority: -1)
    • keyring.backends.SecretService.Keyring (priority: 5)
    • keyring.backends.fail.Keyring (priority: 0)
@mitya57
Copy link
Collaborator

mitya57 commented Jul 29, 2020

Can you please test my PR #453?

@EpicWink
Copy link
Author

#453 fixes the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants