From 233226e9773cb065d6fb2ffce9320e4c885894f3 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Tue, 22 May 2001 19:36:50 +0000 Subject: [PATCH] Per discussion with Barry, make the default value for both get() and setdefault() the empty string. In setdefault(), use + to join the value to create the entry for the headers attribute so that TypeError is raised if the value is of the wrong type. --- Lib/rfc822.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 9093beb211f..14fd2a8cec0 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -421,24 +421,23 @@ class Message: for i in list: del self.headers[i] - def get(self, name, default=None): + def get(self, name, default=""): name = name.lower() if self.dict.has_key(name): return self.dict[name] else: return default - def setdefault(self, name, default=''): + def setdefault(self, name, default=""): lowername = name.lower() if self.dict.has_key(lowername): return self.dict[lowername] else: - default = default or "" - self.dict[lowername] = default - text = "%s: %s" % (name, default) + text = name + ": " + default lines = text.split("\n") for line in lines: self.headers.append(line + "\n") + self.dict[lowername] = default return default def has_key(self, name):