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

Wouter van Heyst larstiq at larstiq.dyndns.org
Sat Jun 10 14:53:05 BST 2006


On Sat, Jun 10, 2006 at 08:27:58AM -0500, John Arbash Meinel wrote:
<snip>
> Actually, I tracked down this bug. The problem is that when you call:
> 
> codecs.getwriter(output_encoding)(sys.stdout, errors=self.encoding_type)
> 
> It returns a file-like object which will use the supplied
> 'output_encoding' to transparently encode your strings before sending
> them to sys.stdout. It works as a wrapper around any file.
> 
> The problem is that it uses __getattr__ to return any special attributes
> directly from the wrapped object, but it doesn't set '.encoding' itself.
> 
> So even though you have wrapped 'sys.stdout' with something that does
> have a proper encoding, checking outf.encoding will return None.
> 
> Elsewhere in the code, I assume that 'self.outf.encoding' is correct.
> 
> The attached patch just sets the self.outf.encoding to the right value,
> so that we can detect it properly later.
> This fixes Wouter's 'bzr pull | less' bug.

When I try to apply the bundle with:
    bzr merge fix-self.outf.encoding.bundle
I get
    bzr: ERROR: Revision {john at arbash-meinel.com-20060610125702-5eecc3274f00e576} not present in inventory.

Is this the right way to apply the bundle? Applying with patch -p0 still
works and fixes the problem, +1 from me.

Wouter van Heyst




More information about the bazaar mailing list