[Python-Dev] Logging, Unicode and sockets (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Thu Oct 8 21:00:34 CEST 2009


I've noticed that the socket-based logging handlers - SocketHandler, DatagramHandler and SysLogHandler - aren't Unicode-aware and can break in the presence of Unicode messages.

I can't understand what the problem with SocketHandler/DatagramHandler is. As they use pickle, they should surely be able to send records with Unicode strings in them, no?

OTOH, why is SMTPHandler not in your list?

I'd like to fix this by giving these handlers an optional (encoding=None) parameter in their init, and then using this to encode on output.

For syslog, I don't think that's appropriate. I presume this is meant to follow RFC 5424? If so, it SHOULD send the data in UTF-8, in which case it MUST include a BOM also. A.8 then says that if you are not certain that it is UTF-8 (which you wouldn't be if the application passes a byte string), you MAY omit the BOM.

Regards, Martin



More information about the Python-Dev mailing list