From 26771923f661671ce4c27f6e45995e2f9b0edb96 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 1 Oct 2004 21:25:01 +0000 Subject: [PATCH] Allow None in IrcDict and InsensitivePreservingDicts. --- src/ircutils.py | 5 ++++- src/utils.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ircutils.py b/src/ircutils.py index 7c075a5ab..39db26fb2 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -493,7 +493,10 @@ class IrcString(str): class IrcDict(utils.InsensitivePreservingDict): """Subclass of dict to make key comparison IRC-case insensitive.""" - key = staticmethod(toLower) + def key(self, s): + if s is not None: + s = toLower(s) + return s class IrcSet(utils.NormalizingSet): diff --git a/src/utils.py b/src/utils.py index c171ea5f6..23d971ba3 100755 --- a/src/utils.py +++ b/src/utils.py @@ -641,7 +641,12 @@ def isIPV6(s): return False class InsensitivePreservingDict(UserDict.DictMixin, object): - key = staticmethod(str.lower) + def key(self, s): + """Override this if you wish.""" + if s is not None: + s = s.lower() + return s + def __init__(self, dict=None, key=None): if key is not None: self.key = key