diff options
author | Fred Drake <fdrake@acm.org> | 2001-05-22 19:36:50 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-05-22 19:36:50 (GMT) |
commit | 233226e9773cb065d6fb2ffce9320e4c885894f3 (patch) | |
tree | 2d80fed70eb10943ed1889638bc1cf7b49ae337d /Lib/rfc822.py | |
parent | d97422115e9ed6498bc7a6f792a0bf8f278f9097 (diff) | |
download | cpython-233226e9773cb065d6fb2ffce9320e4c885894f3.zip cpython-233226e9773cb065d6fb2ffce9320e4c885894f3.tar.gz cpython-233226e9773cb065d6fb2ffce9320e4c885894f3.tar.bz2 |
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.
Diffstat (limited to 'Lib/rfc822.py')
-rw-r--r-- | Lib/rfc822.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 9093beb..14fd2a8 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): |