This is an alternative to #3140. As @puiterwijk figured out,
when a new commit notification mail would contain non-ASCII
text - i.e. when the commit author's full name or the commit
topic contain non-ASCII text - sending the mail would fail. In
3.x at least, this resulted in the service that sends the mails
silently getting stuck; we don't know how the service behaves
when this happens in current git (it was changed from trollius
to celery), but the underlying bug is still there.
It fails because of unicode conversion issues in the new commit
notification function. send_email expects the body text to be
provided as a unicode instance, but notify_new_commits works
with str instances throughout (including the commit author and
commit topic values; these ultimately come in as UTF-8 encoded
strings, from the pagure.git.read_output function). Ultimately
it produces a UTF-8 encoded str which send_email then tries
to encode again, and that crashes.
This approach fixes the problem in a way that's as consistent
as possible with the other functions in the file - the body text
is produced by %s-style string formatting of a unicode, and we
ensure the things that get put into it are also unicode type,
for the ones which can contain non-ASCII text. I also added some
comments about this area, noted the expected type for text in
the send_email docstring, and added a test.
This is an alternative to #3140. As @puiterwijk figured out,
when a new commit notification mail would contain non-ASCII
text - i.e. when the commit author's full name or the commit
topic contain non-ASCII text - sending the mail would fail. In
3.x at least, this resulted in the service that sends the mails
silently getting stuck; we don't know how the service behaves
when this happens in current git (it was changed from trollius
to celery), but the underlying bug is still there.
It fails because of unicode conversion issues in the new commit
notification function.
send_emailexpects the body text to beprovided as a
unicodeinstance, butnotify_new_commitsworkswith
strinstances throughout (including the commit author andcommit topic values; these ultimately come in as UTF-8 encoded
strings, from the
pagure.git.read_outputfunction). Ultimatelyit produces a UTF-8 encoded
strwhichsend_emailthen triesto encode again, and that crashes.
This approach fixes the problem in a way that's as consistent
as possible with the other functions in the file - the body text
is produced by
%s-style string formatting of a unicode, and weensure the things that get put into it are also unicode type,
for the ones which can contain non-ASCII text. I also added some
comments about this area, noted the expected type for
textinthe
send_emaildocstring, and added a test.Fixes https://pagure.io/pagure/issue/1814
Signed-off-by: Adam Williamson awilliam@redhat.com