Skip to content

Commit

Permalink
yum-cron: make sure self.output is fully unicode. BZ 1425776
Browse files Browse the repository at this point in the history
Closes #97.
  • Loading branch information
dmnks committed Feb 12, 2020
1 parent edd5fb3 commit a866ccd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion yum-cron/yum-cron.py
Expand Up @@ -140,7 +140,11 @@ def sendMessages(self):
overridden by inheriting classes to emit the messages
according to their individual methods.
"""
pass
# Convert any byte strings to unicode objects now (so that we avoid
# implicit conversions with the "ascii" codec later when join()-ing the
# strings, leading to tracebacks).
self.output = [x.decode('utf-8') if isinstance(x, str) else x
for x in self.output]


class EmailEmitter(UpdateEmitter):
Expand Down Expand Up @@ -220,6 +224,7 @@ def sendMessages(self):
"""Combine the stored messages that have been stored into a
single email message, and send this message.
"""
super(EmailEmitter, self).sendMessages()
# Don't send empty emails
if not self.output:
return
Expand Down Expand Up @@ -262,6 +267,7 @@ def sendMessages(self) :
"""Combine the stored messages that have been stored into a
single email message, and send this message to standard output.
"""
super(StdIOEmitter, self).sendMessages()
# Don't print blank lines
if not self.output:
return
Expand Down

0 comments on commit a866ccd

Please sign in to comment.