mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Message.__delitem__(): If the key doesn't exist in the dictionary,
raise KeyError instead of failing silently!
This commit is contained in:
parent
75ae7e7dfa
commit
81ffe75d1c
1 changed files with 5 additions and 5 deletions
|
@ -397,11 +397,11 @@ class Message:
|
||||||
|
|
||||||
def __delitem__(self, name):
|
def __delitem__(self, name):
|
||||||
"""Delete all occurrences of a specific header, if it is present."""
|
"""Delete all occurrences of a specific header, if it is present."""
|
||||||
name = string.lower(name)
|
lowname = string.lower(name)
|
||||||
if not self.dict.has_key(name):
|
if not self.dict.has_key(lowname):
|
||||||
return
|
raise KeyError, name
|
||||||
del self.dict[name]
|
del self.dict[lowname]
|
||||||
name = name + ':'
|
name = lowname + ':'
|
||||||
n = len(name)
|
n = len(name)
|
||||||
list = []
|
list = []
|
||||||
hit = 0
|
hit = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue