Skip to content

Commit

Permalink
imapwidget: Do not pass None as username to keyring.get_password()
Browse files Browse the repository at this point in the history
Ensure not to pass `None` as the username to `keyring.get_password()`,
as the API requires it to always be a `str` and some backends
(particularly `keyrings-alt`) crash on `None`.

Fixes qtile#4609
  • Loading branch information
mgorny authored and elParaguayo committed Dec 2, 2023
1 parent 9ccaf6f commit 0632d78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libqtile/widget/imapwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import keyring

from libqtile.confreader import ConfigError
from libqtile.log_utils import logger
from libqtile.widget import base

Expand Down Expand Up @@ -75,6 +76,8 @@ class ImapWidget(base.ThreadPoolText):
def __init__(self, **config):
base.ThreadPoolText.__init__(self, "", **config)
self.add_defaults(ImapWidget.defaults)
if self.user is None:
raise ConfigError("You must set the 'user' parameter for the IMAP widget.")
password = keyring.get_password("imapwidget", self.user)
if password is not None:
self.password = password
Expand Down
1 change: 1 addition & 0 deletions test/widgets/test_widget_init_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

# To skip a test entirely, list the widget class here
no_test = [widgets.Mirror, widgets.PulseVolume] # Mirror requires a reflection object
no_test += [widgets.ImapWidget] # Requires a configured username

# To test a widget only under one backend, list the widget class here
exclusive_backend = {
Expand Down

0 comments on commit 0632d78

Please sign in to comment.