user_encoding fix
Alexander Belchenko
bialix at ukr.net
Mon Feb 20 15:26:25 GMT 2006
Nir Soffer пишет:
>
> On 20/02/2006, at 12:42, Alexander Belchenko wrote:
>>
>> So, I think right code should be as following:
>>
>> if getattr(sys.stdout, "encoding", "ascii") not in (None, "ascii"):
>> encoding = sys.stdout.encoding
>> else:
>> encoding = bzrlib.user_encoding
>
> Sounds good, but on Mac OS X I get 'US-ASCII', so you need this:
>
> if getattr(sys.stdout, 'encoding', None) not in (None, 'ascii',
> 'US-ASCII'):
> encoding = sys.stdout.encoding
> else:
> encoding = bzrlib.user_encoding
+1 on this variant. John, what you say about this?
> btw, when running with a pipe, sys.stdout does have encoding and is set
> to None.
Probably, you're right. I don't remeber exactly in which case sys.stdout
or sys.stdin(?) does not have encoding attribute at all.
--
Alexander
More information about the bazaar
mailing list