]> granicus.if.org Git - python/commitdiff
append(): Bite the bullet and let charset be the string name of a
authorBarry Warsaw <barry@python.org>
Tue, 23 Jul 2002 06:08:10 +0000 (06:08 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 23 Jul 2002 06:08:10 +0000 (06:08 +0000)
character set, which we'll convert to a Charset instance.  Sigh.

Lib/email/Header.py

index e691c3cb0e975ea3f27a1c70aaa2563bb8f505b7..2457279013bfdc9f51ce7e62e026250fb8b053d1 100644 (file)
@@ -188,12 +188,15 @@ class Header:
     def append(self, s, charset=None):
         """Append string s with Charset charset to the MIME header.
 
-        charset defaults to the one given in the class constructor.  If
-        charset is given, it should be an instance of Charset (not a character
-        set name string!).
+        If charset is given, it should be a Charset instance, or the name of a
+        character set (which will be converted to a Charset instance).  A
+        value of None (the default) means charset is the one given in the
+        class constructor.
         """
         if charset is None:
             charset = self._charset
+        elif not isinstance(charset, Charset):
+            charset = Charset(charset)
         self._chunks.append((s, charset))
 
     def _split(self, s, charset, firstline=0):