About encoding issues

Martin Pool mbp at sourcefrog.net
Mon Apr 24 04:06:58 BST 2006


On 24/04/2006, at 12:59 PM, Martin Pool wrote:
>>
>> and see what happens. Unfortunately the errors it gave were pretty  
>> useless:
>>
>> Traceback (most recent call last):
>>   File "/usr/lib/python2.4/logging/__init__.py", line 739, in emit
>>   File "/usr/lib/python2.4/encodings/undefined.py", line 22, in  
>> decode
>>     raise UnicodeError, "undefined encoding"
>> UnicodeError: undefined encoding
>
> Perhaps we're initializing logging in a way that provokes this?  It  
> does seem possible to load and use logging with the default  
> encoding of undefined.

Of course what's happening is that we currently use ascii literals in  
Python (regular double-quoted strings) for many of the messages that  
bzr sends to the user or to the log file.  Both the user's terminal  
and the log file are potentially unicode in a particular  
representation, so for a string to get there it needs to first be  
Unicode and then be encoded in the right way.  However, if the  
literals are byte strings and implicit conversion is disabled, we  
can't print them.

We can fix this by either making them u"" unicode literals, or  
explicitly converting in the places that print them.  It may be  
worthwhile doing so that we can get errors on implicit conversion of  
non-ascii strings.

-- 
Martin







More information about the bazaar mailing list