1. Christian Karrié
  2. django-hg-git

Commits

Claude Paroz  committed b0f9222

Fixed #19107 -- Workarounded message-encoding bug on Python < 2.6.6

Thanks Bernardo Pires for the report.

  • Participants
  • Parent commits b4ac822
  • Branches default

Comments (0)

Files changed (1)

File django/core/mail/message.py

View file
  • Ignore whitespace
 import mimetypes
 import os
 import random
+import sys
 import time
 from email import charset as Charset, encoders as Encoders
 from email.generator import Generator
         """
         fp = six.StringIO()
         g = Generator(fp, mangle_from_ = False)
+        if sys.version_info < (2, 6, 6) and isinstance(self._payload, six.text_type):
+            # Workaround for http://bugs.python.org/issue1368247
+            self._payload = self._payload.encode(self._charset.output_charset)
         g.flatten(self, unixfrom=unixfrom)
         return fp.getvalue()