Commit 280c1a65 authored by Florian Apolloner's avatar Florian Apolloner
Browse files

Worked around a bug in python 3.3.3. Refs #21093

parent 6a613614
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -167,6 +167,13 @@ class SafeMIMEText(MIMEMixin, MIMEText):
            # We do it manually and trigger re-encoding of the payload.
            MIMEText.__init__(self, text, subtype, None)
            del self['Content-Transfer-Encoding']
            # Work around a bug in python 3.3.3 [sic], see
            # http://bugs.python.org/issue19063 for details.
            if sys.version_info[:3] == (3, 3, 3):
                payload = text.encode(utf8_charset.output_charset)
                self._payload = payload.decode('ascii', 'surrogateescape')
                self.set_charset(utf8_charset)
            else:
                self.set_payload(text, utf8_charset)
            self.replace_header('Content-Type', 'text/%s; charset="%s"' % (subtype, charset))
        else: