Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Worked around a bug in python 3.3.3. Refs #21093

  • Loading branch information...
commit 280c1a65ccacd679bf298bf2b169ff01e7266b8e 1 parent 6a61361
@apollo13 apollo13 authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 django/core/mail/message.py
View
9 django/core/mail/message.py
@@ -167,7 +167,14 @@ def __init__(self, text, subtype, charset):
# We do it manually and trigger re-encoding of the payload.
MIMEText.__init__(self, text, subtype, None)
del self['Content-Transfer-Encoding']
- self.set_payload(text, utf8_charset)
+ # 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:
MIMEText.__init__(self, text, subtype, charset)
Please sign in to comment.
Something went wrong with that request. Please try again.