]> granicus.if.org Git - python/commitdiff
__unicode__(): Patch # 541263 by Mikhail Zabaluev, implementation
authorBarry Warsaw <barry@python.org>
Sat, 29 Jun 2002 03:26:58 +0000 (03:26 +0000)
committerBarry Warsaw <barry@python.org>
Sat, 29 Jun 2002 03:26:58 +0000 (03:26 +0000)
modified by Barry.

Lib/email/Header.py

index c72f64d7ba082585e99835091562ec795a0a8232..e02ccb80292b5d64ea402515719827ca7ce5fba3 100644 (file)
@@ -142,6 +142,12 @@ class Header:
         """A synonym for self.encode()."""
         return self.encode()
 
+    def __unicode__(self):
+        """Helper for the built-in unicode function."""
+        # charset item is a Charset instance so we need to stringify it.
+        uchunks = [unicode(s, str(charset)) for s, charset in self._chunks]
+        return u''.join(uchunks)
+
     def append(self, s, charset=None):
         """Append string s with Charset charset to the MIME header.