<p dir="auto">I'm using django-celery to send emails. In development, I set <code class="notranslate">EMAIL_BACKEND</code> to <code class="notranslate">django.core.mail.backends.console.EmailBackend</code> so the email output will go straight to the celeryd console. When the content of the email contains a unicode character, celery.log barfs on line 56:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2013-05-02 12:54:15,353: WARNING/PoolWorker-2] &lt;Unrepresentable &lt;type 'unicode'&gt;: UnicodeDecodeError('ascii', '\x1b[1;33mContent-Type: text/plain; charset=&quot;utf-8&quot;\nMIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\nSubject: TulsaWebDevs was edited by groovezilla\nFrom: notifications@support.mozilla.com\nTo: luke.crouch@gmail.com\nDate: Thu, 02 May 2013 19:54:15 -0000\nMessage-ID: &lt;20130502195415.5969.22584@developer-local.allizom.org&gt;\n\ngroovezilla created a new revision to the document TulsaWebDevs.\n\nTo view this document\'s history, click the following link, or paste it into your browser\'s location bar:\n\nhttps://developer.mozilla.org/en-US/docs/TulsaWebDevs$history\n\n--\nChanges:\n--- [en-US] TulsaWebDevs #27\n\n+++ [en-US] TulsaWebDevs #28\n\n@@ -11,7 +11,7 @@\n\n       Meets every 3rd Monday of each month at the i2E Tulsa office for web technology presentations.\n     &lt;/p&gt;\n     &lt;p&gt;\n-      Meets every Friday at Fab Lab Tulsa for coworking, which is not quit\xc3\xa9\xc3\xa9 good enough.\n+      Meets every Friday at Fab Lab Tulsa for coworking, which is not quit\xc3\xa9 good enough.\n     &lt;/p&gt;\n     &lt;h2 id=&quot;History&quot;&gt;\n       History\n\n--\nUnsubscribe from these emails:\nhttps://developer.mozilla.org/unsubscribe/1?s=KWnEcxVsDx\x1b[0m', 842, 843, 'ordinal not in range(128)')&gt;
Traceback (most recent call last):
  File &quot;/vagrant/vendor/packages/celery/celery/log.py&quot;, line 56, in format
    record.msg = safe_str(str_t(color(record.msg)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 842: ordinal not in range(128)"><pre class="notranslate"><code class="notranslate">[2013-05-02 12:54:15,353: WARNING/PoolWorker-2] &lt;Unrepresentable &lt;type 'unicode'&gt;: UnicodeDecodeError('ascii', '\x1b[1;33mContent-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\nSubject: TulsaWebDevs was edited by groovezilla\nFrom: notifications@support.mozilla.com\nTo: luke.crouch@gmail.com\nDate: Thu, 02 May 2013 19:54:15 -0000\nMessage-ID: &lt;20130502195415.5969.22584@developer-local.allizom.org&gt;\n\ngroovezilla created a new revision to the document TulsaWebDevs.\n\nTo view this document\'s history, click the following link, or paste it into your browser\'s location bar:\n\nhttps://developer.mozilla.org/en-US/docs/TulsaWebDevs$history\n\n--\nChanges:\n--- [en-US] TulsaWebDevs #27\n\n+++ [en-US] TulsaWebDevs #28\n\n@@ -11,7 +11,7 @@\n\n       Meets every 3rd Monday of each month at the i2E Tulsa office for web technology presentations.\n     &lt;/p&gt;\n     &lt;p&gt;\n-      Meets every Friday at Fab Lab Tulsa for coworking, which is not quit\xc3\xa9\xc3\xa9 good enough.\n+      Meets every Friday at Fab Lab Tulsa for coworking, which is not quit\xc3\xa9 good enough.\n     &lt;/p&gt;\n     &lt;h2 id="History"&gt;\n       History\n\n--\nUnsubscribe from these emails:\nhttps://developer.mozilla.org/unsubscribe/1?s=KWnEcxVsDx\x1b[0m', 842, 843, 'ordinal not in range(128)')&gt;
Traceback (most recent call last):
  File "/vagrant/vendor/packages/celery/celery/log.py", line 56, in format
    record.msg = safe_str(str_t(color(record.msg)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 842: ordinal not in range(128)
</code></pre></div>
<p dir="auto">Colored celery console logger fails to display unicode strings containing non-ascii letters (e.g. django's sql query log with non-ascii data):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="UnicodeEncodeError: 'ascii' codec can't encode characters in position 91-95: ordinal not in range(128)
Traceback (most recent call last):
  File &quot;/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py&quot;, line 776, in emit
    msg = self.format(record)
  File &quot;/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py&quot;, line 654, in format
    return fmt.format(record)
  File &quot;/Users/kmike/envs/zina/lib/python2.6/site-packages/celery/log.py&quot;, line 56, in format
    t = logging.Formatter.format(self, record)
  File &quot;/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py&quot;, line 439, in format
    s = self._fmt % record.__dict__
  File &quot;/Users/kmike/envs/zina/lib/python2.6/site-packages/celery/utils/term.py&quot;, line 62, in __str__
    return prefix + str(reduce(self._add, self.s)) + suffix"><pre class="notranslate"><code class="notranslate">UnicodeEncodeError: 'ascii' codec can't encode characters in position 91-95: ordinal not in range(128)
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/Users/kmike/envs/zina/lib/python2.6/site-packages/celery/log.py", line 56, in format
    t = logging.Formatter.format(self, record)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", line 439, in format
    s = self._fmt % record.__dict__
  File "/Users/kmike/envs/zina/lib/python2.6/site-packages/celery/utils/term.py", line 62, in __str__
    return prefix + str(reduce(self._add, self.s)) + suffix
</code></pre></div>
<p dir="auto">As a workaround I set <code class="notranslate">CELERYD_HIJACK_ROOT_LOGGER = False</code> and then add 'logging.StreamHandler' to 'celery' logger (it handles non-ascii data).</p>