mirror of https://github.com/django/django.git
Fixed #19107 -- Workarounded message-encoding bug on Python < 2.6.6
Thanks Bernardo Pires for the report.
This commit is contained in:
parent
0614e99fbd
commit
501d793398
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from email import charset as Charset, encoders as Encoders
|
from email import charset as Charset, encoders as Encoders
|
||||||
from email.generator import Generator
|
from email.generator import Generator
|
||||||
|
@ -138,6 +139,9 @@ class SafeMIMEText(MIMEText):
|
||||||
"""
|
"""
|
||||||
fp = six.StringIO()
|
fp = six.StringIO()
|
||||||
g = Generator(fp, mangle_from_ = False)
|
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)
|
g.flatten(self, unixfrom=unixfrom)
|
||||||
return fp.getvalue()
|
return fp.getvalue()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue