Merge pull request #9501 from Ultimaker/CURA-7180_keyring_none_value

Handle storing None values in keyring
This commit is contained in:
Remco Burema 2021-04-06 12:31:45 +02:00 committed by GitHub
commit 40fb430277
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,8 @@ class KeyringAttribute:
def __get__(self, instance: Type["BaseModel"], owner: type) -> str:
if self._store_secure:
try:
return keyring.get_password("cura", self._keyring_name)
value = keyring.get_password("cura", self._keyring_name)
return value if value != "" else None
except NoKeyringError:
self._store_secure = False
Logger.logException("w", "No keyring backend present")
@ -41,7 +42,7 @@ class KeyringAttribute:
if self._store_secure:
setattr(instance, self._name, None)
try:
keyring.set_password("cura", self._keyring_name, value)
keyring.set_password("cura", self._keyring_name, value if value is not None else "")
except PasswordSetError:
self._store_secure = False
if self._name not in DONT_EVER_STORE_LOCALLY: