From c48852e3bbe3eb9345aa248e69d48302d865e782 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 5 Sep 2019 20:22:39 +0000 Subject: [PATCH] Detect values of None in utils.get_irc() The intent for the get_irc() function is to return an empty string when no nick is found, but the API tends to provide a null (None) value explicitly. When this happens, convert it to the empty string too. Change-Id: I9b62b1d722136246d1987a1a45ca771bdc02579c --- openstack_election/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openstack_election/utils.py b/openstack_election/utils.py index 39cf3a35..79fa46e5 100644 --- a/openstack_election/utils.py +++ b/openstack_election/utils.py @@ -178,6 +178,9 @@ def get_irc(member, filepath=None): member_data = member.get('data', []) if member_data: irc = member_data[0].get('irc', '') + # The API can return None for nonexistent nicks + if irc is None: + irc = '' return irc