Message.__delitem__(): If the key doesn't exist in the dictionary,

raise KeyError instead of failing silently!
This commit is contained in:
Fred Drake 1999-09-10 20:54:53 +00:00
parent 75ae7e7dfa
commit 81ffe75d1c
1 changed files with 5 additions and 5 deletions

View File

@ -397,11 +397,11 @@ class Message:
def __delitem__(self, name):
"""Delete all occurrences of a specific header, if it is present."""
name = string.lower(name)
if not self.dict.has_key(name):
return
del self.dict[name]
name = name + ':'
lowname = string.lower(name)
if not self.dict.has_key(lowname):
raise KeyError, name
del self.dict[lowname]
name = lowname + ':'
n = len(name)
list = []
hit = 0