summaryrefslogtreecommitdiff
path: root/x11-wm/qtile/files/qtile-0.23.0-keyring.patch
blob: c4a44efd87910a7c4d17cf78c45d428f6bf39861 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 84eaf6b70f9569c88534dc8054e19f05fa3137e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sat, 2 Dec 2023 17:40:50 +0100
Subject: [PATCH] imapwidget: Do not pass None as username to
 keyring.get_password()

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 #4609
---
 libqtile/widget/imapwidget.py              | 3 +++
 test/widgets/test_widget_init_configure.py | 1 +
 2 files changed, 4 insertions(+)

diff --git a/libqtile/widget/imapwidget.py b/libqtile/widget/imapwidget.py
index 3f84d9e7..c8a6ec0e 100644
--- a/libqtile/widget/imapwidget.py
+++ b/libqtile/widget/imapwidget.py
@@ -24,6 +24,7 @@ import re
 
 import keyring
 
+from libqtile.confreader import ConfigError
 from libqtile.log_utils import logger
 from libqtile.widget import base
 
@@ -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
diff --git a/test/widgets/test_widget_init_configure.py b/test/widgets/test_widget_init_configure.py
index 83a9cb9a..aa7a1f9b 100644
--- a/test/widgets/test_widget_init_configure.py
+++ b/test/widgets/test_widget_init_configure.py
@@ -58,6 +58,7 @@ extras = [
 
 # 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 = {
-- 
2.43.0