brack3t/Djrill — pull request #65 by winhamwr (2014-04-23 21:03:51+00:00)
Title: `UnicodeEncodeError` with unicode attachments

If an attachment is added that contains unicode, sending the message fails with a `UnicodeEncodeError`. I have a branch with a failing test:

```
ERROR: test_unicode_attachment_correctly_decoded (djrill.tests.test_mandrill_send.DjrillBackendTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/wes/policystat/workspace/Djrill/djrill/tests/test_mandrill_send.py", line 194, in test_unicode_attachment_correctly_decoded
email.send()
File "/home/wes/policystat/workspace/Djrill/Django-1.6.3-py2.7.egg/django/core/mail/message.py", line 274, in send
return self.get_connection(fail_silently).send_messages([self])
File "/home/wes/policystat/workspace/Djrill/djrill/mail/backends/djrill.py", line 68, in send_messages
sent = self._send(message)
File "/home/wes/policystat/workspace/Djrill/djrill/mail/backends/djrill.py", line 89, in _send
self._add_attachments(message, msg_dict)
File "/home/wes/policystat/workspace/Djrill/djrill/mail/backends/djrill.py", line 257, in _add_attachments
att_dict, is_embedded = self._make_mandrill_attachment(attachment, str_encoding)
File "/home/wes/policystat/workspace/Djrill/djrill/mail/backends/djrill.py", line 298, in _make_mandrill_attachment
content_b64 = b64encode(content)
File "/usr/lib/python2.7/base64.py", line 53, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 3: ordinal not in range(128)

```

My plan is to treat python2.X like we're currently treating python3 by first converting to bytes.