Merge pull request #1396 from ynput/bugfix/failing-keyring-backend

Local settings: Capture 'ItemNotFoundException' error if possible
This commit is contained in:
Jakub Trllo 2025-08-01 12:20:12 +02:00 committed by GitHub
commit 5daf341d63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -130,6 +130,10 @@ def get_addons_resources_dir(addon_name: str, *args) -> str:
return os.path.join(addons_resources_dir, addon_name, *args)
class _FakeException(Exception):
"""Placeholder exception used if real exception is not available."""
class AYONSecureRegistry:
"""Store information using keyring.
@ -205,7 +209,17 @@ class AYONSecureRegistry:
"""
import keyring
value = keyring.get_password(self._name, name)
# Capture 'ItemNotFoundException' exception (on linux)
try:
from secretstorage.exceptions import ItemNotFoundException
except ImportError:
ItemNotFoundException = _FakeException
try:
value = keyring.get_password(self._name, name)
except ItemNotFoundException:
value = None
if value is not None:
return value