Commit 860953de authored by ale's avatar ale
Browse files

Fix handling of unicode strings in

The syslog module will throw a TypeError, not a UnicodeError, if
you give syslog() a unicode string.
parent 7404898f
Pipeline #3511 passed with stages
in 4 minutes and 26 seconds
......@@ -80,14 +80,14 @@ class _Syslog:
except Exception, e:
msg = 'Bad format "%s": %s: %s' % (origmsg, repr(e), e)
logf.write(msg + '\n')
except UnicodeError:
except (UnicodeError, TypeError):
# Python 2.4 may fail to write 8bit (non-ascii) characters
# Also, if msg is unicode with non-ascii, quopri.encodestring()
# will throw UnicodeEncodeError, so avoid that.
if isinstance(msg, unicode):
msg = msg.encode('iso-8859-1', 'replace')
logf.write(quopri.encodestring(msg) + '\n')
# For the ultimate in convenience
__call__ = write
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment