Why BOM in logging message?

Roy Smith roy at panix.com
Thu Jan 10 11:06:40 EST 2013


In article <roy-10B053.20174309012013 at news.panix.com>,
Roy Smith  <roy at panix.com> wrote:
>In article <mailman.344.1357772847.2939.python-list at python.org>,
> Chris Angelico <rosuav at gmail.com> wrote:
>
>> On Thu, Jan 10, 2013 at 9:54 AM, Roy Smith <roy at panix.com> wrote:
>> > What's weird is that two of the servers, and only those two, stick a
>> > BOM (Byte Order Mark) in front of the message they log.
>> 
>> Could it be this issue you're looking at?
>> 
>> http://bugs.python.org/issue14452
>> 
>> What are the exact Python versions in use? Are the two different
>> servers running an older revision of Py 2.7?
>> 
>> ChrisA
>
>It sounds like it might be it, but we're running 2.7.3 on all machines.

Well, this is fascinating.  It turns out that while all of our
machines report that they're running 2.7.3, they have two different
versions of /usr/lib/python2.7/logging/handlers.py!

-rw-r--r-- 1 root root 45076 Aug  1 05:39 /usr/lib/python2.7/logging/handlers.py
-rw-r--r-- 1 root root 45143 Apr 20  2012 /usr/lib/python2.7/logging/handlers.py

The April 24th version has the BOM code in SysLogHander.emit():

|         # Message is a string. Convert to bytes as required by RFC 5424
|        if type(msg) is unicode:
|            msg = msg.encode('utf-8')
|            if codecs:
|                msg = codecs.BOM_UTF8 + msg
|        msg = prio + msg

and the August 1st version doesn't:

|        # Message is a string. Convert to bytes as required by RFC 5424
|        if type(msg) is unicode:
|            msg = msg.encode('utf-8')
|        msg = prio + msg

Is it possible there's two different 2.7.3 builds that somehow got
packaged by Ubuntu at different times?  The pattern of which machines
have the August code and which have the April code correlates with
when we rolled out each server instance.



More information about the Python-list mailing list