[BUNDLE] Make additional chance to obtain right encoding of console when output piped

Alexander Belchenko bialix at ukr.net
Sat Jun 10 09:19:38 BST 2006


Wouter van Heyst пишет:
> On Fri, Jun 09, 2006 at 07:57:49PM +0300, Alexander Belchenko wrote:
>> I wrote about this fact before: when output of bzr command piped to
>> another program, i.e. when run something like:
>>
>> bzr log | less
>>
>> Then sys.stdout lose their own encoding attribute value and bzr switch
>> to use bzrlib.user_encoding value. That behaviour on some system is
>> inappropriate, see bug 5041 as example.
>>
>> But when only stdout piped out then stdin is not touched and behaves
>> normally. So bzr should try to use information from sys.stdin.encoding
>> to detect *right* encoding of console.
> 
> This doesn't seem enough for 'bzr pull | less' though.
> 
> bzr: ERROR: exceptions.TypeError: encode() argument 1 must be string, not None
>  at /home/larstiq/src/bzr/bzr.dev/bzrlib/urlutils.py line 468
>  in unescape_for_display

This error raised with or without my patch? Because in patch checked 
encoding with conditional expression:

if not encoding:
     using default

So, if sys.stdin.encoding is None it was boolean False and in this case 
bzr should use bzrlib.user_encoding value. I'm think that problem in 
your bzrlib.user_encoding value. Can you show what encoding chosen by 
looking at .bzr.log. In .bzr.log you can see line something like:

encoding stdout log as sys.stdin encoding 'cp866'


--
Alexander





More information about the bazaar mailing list