Red Hat Bugzilla – Bug 239182
koji traceback on mail with non-ASCII
Last modified: 2013-01-09 20:37:56 EST
My perltidy build succeeded (I think), but the state is "failed" and there's a
backtrace in the "Result" section, which I guess is triggered by the "ä" in my
Traceback (most recent call last):
File "/usr/sbin/kojid", line 1109, in runTask
response = (handler.run(),)
File "/usr/sbin/kojid", line 1185, in run
File "/usr/sbin/kojid", line 2128, in handler
server.sendmail(from_addr, recipients, message)
File "/usr/lib64/python2.4/smtplib.py", line 696, in sendmail
(code,resp) = self.data(msg)
File "/usr/lib64/python2.4/smtplib.py", line 493, in data
File "/usr/lib64/python2.4/smtplib.py", line 320, in send
File "<string>", line 1, in sendall
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position
588: ordinal not in range(128)
Mike B, thoughts?
Same for me.
We should surely be assuming utf-8 everywhere -- in Content-Type: of all
text/plain parts, and by RFC2047-encoding the headers.
All the data in the database is stored as UTF-8, but comes back from the
database as Python Unicode objects if it contains any non-ASCII characters, and
smtplib apparently doesn't know how to handle Unicode. I just checked in a
change to convert the Unicode to UTF-8-encoded str objects, which should resolve
the problem. There will be an update to Koji soon to deploy this fix in production.
There should be no non-ASCII characters in the email headers, so RFC2047
shouldn't be an issue.
I wonder if we should be using the email module...
I think this should be fixed now.