]> granicus.if.org Git - python/commitdiff
Message.__delitem__(): If the key doesn't exist in the dictionary,
authorFred Drake <fdrake@acm.org>
Fri, 10 Sep 1999 20:54:53 +0000 (20:54 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 10 Sep 1999 20:54:53 +0000 (20:54 +0000)
        raise KeyError instead of failing silently!

Lib/rfc822.py

index 87219949c322ef4715ce1408ad90660e5ca70eb9..dcf059c85a3dbdbbfecb3a9802dab9945153a4ea 100644 (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