Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

Thanks Bernardo Pires for the report.
  • Loading branch information...
commit 501d793398c3ecc3c8a54475d07609cf34643553 1 parent 0614e99
@claudep claudep authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 django/core/mail/message.py
View
4 django/core/mail/message.py
@@ -3,6 +3,7 @@
import mimetypes
import os
import random
+import sys
import time
from email import charset as Charset, encoders as Encoders
from email.generator import Generator
@@ -138,6 +139,9 @@ def as_string(self, unixfrom=False):
"""
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()
Please sign in to comment.
Something went wrong with that request. Please try again.