Skip to content

Commit

Permalink
Catch KeyringError and RuntimeError when accessing keyring.
Browse files Browse the repository at this point in the history
* src/poetry/utils/password_manager.py (PoetryKeyring.get_credential)
  • Loading branch information
real-yfprojects committed Aug 13, 2023
1 parent 9e47cd9 commit a66935a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/poetry/utils/password_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ def get_credential(

import keyring

from keyring.errors import KeyringError
from keyring.errors import KeyringLocked

for name in names:
credential = None
try:
credential = keyring.get_credential(name, username)
except keyring.errors.KeyringLocked:
except KeyringLocked:
logger.debug("Keyring %s is locked", name)
credential = None
except (KeyringError, RuntimeError):
logger.debug("Accessing keyring %s failed", name, exc_info=True)

if credential:
return HTTPAuthCredential(
username=credential.username, password=credential.password
Expand Down

0 comments on commit a66935a

Please sign in to comment.