severb/graypy — pull request #38 by shylent (2013-10-24 09:00:11+00:00)
Title: Sanitize values in message_dict before serializing to json

If one attempts to log a message, that is a bytestring containing invalid utf-8, json.dumps in makePickle raises UnicodeDecodeError. This pull request attempts to fix this by sanitizing offending values in message_dict using repr. While attempting to log raw byte sequences is not particularly a good idea, a logging library by any means should not just error out, it should make the best effort to log the message, whatever it contains (that is the behaviour of loggers / handlers in the standard library).

Tests, demonstrating erroneous behaviour are also included.