[PATCH] More non-ASCII environment cleanups

Joel Rosdahl joel at rosdahl.net
Wed Oct 26 11:23:22 BST 2005


Jan Hudec <bulb at ucw.cz> writes:

> On Mon, Oct 24, 2005 at 22:11:44 +0200, Joel Rosdahl wrote:
> 
>> There are lots of places in the current bzr code where the print
>> statement is used to write Unicode strings to standard output. But
>> that doesn't work when sys.stdout.encoding isn't set (and it isn't
>> always, for example if standard output is redirected to a file). 
>> Therefore, I created a function called bzrlib.osutils.myprint (I
>> wouldn't mind a better name or another location) and replaced many
>> of the print statements with it. For consistency reasons, myprint
>> is also used to print integers and ASCII-safe strings in some
>> places.
>
> Why don't you just set sys.stdout.encoding if it is not set. IMHO
> this python only setting it only if it is a terminal is broken. I'd
> say bzrlib should require it being set and bzr should set it.

That's not possible since it's a read-only attribute. See
<http://docs.python.org/lib/bltin-file-objects.html#l2h-252>.

-- 
Regards,
Joel Rosdahl <joel at rosdahl.net>
Key BB845E97; fingerprint 9F4B D780 6EF4 5700 778D  8B22 0064 F9FF BB84 5E97




More information about the bazaar mailing list