Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; 'distutils': 0.07; 'supported,': 0.09; 'sys,': 0.09; 'cc:addr:python-list': 0.11; '>>': 0.16; 'codecs': 0.16; 'subject:Unicode': 0.16; 'subject:ideas': 0.16; 'sys.stderr': 0.16; 'sys.stdout': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'seems': 0.21; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'cheers,': 0.24; '>': 0.26; 'logging': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'stuff': 0.32; 'url:python': 0.33; 'cc:no real name:2**1': 0.33; 'etc': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'list': 0.37; 'email addr:python.org': 0.37; 'nov': 0.38; 'skip:_ 40': 0.38; 'mailing': 0.39; 'url:mail': 0.40; 'skip:c 50': 0.60; 'containing': 0.69; 'shadow': 0.84; 'streams': 0.84; 'officially': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=B7+OXv3NTBu5GFjuyvuOQmhlIzER/HS1SeReVjx3RJM=; b=GLY+ptlWJuIOgi/47sB/OuF4TzTwK+I5F4ACSSMtnR8k0vI+z+3kCiqGSMyRhRKiUt EJwCWgGveXciSH+zvxg4/1DmFvufKP8lf4Z60YEP7iCnoLeG9/dlLd21G/goZl2Dws1r 8RuRrDNeOa5U+IVtF3dGoNNNif5Sc2vQsfr3CouRCcwMtNq4WtcBKdCuKyFOAiYKwbaU jwDOHVjVGgJH1CAbptvFCKfbGtnJ9vJcFao+kjfswHXNEjoF8LmujhbPJph11QssCTpi shdzs/6k44EeFfXP1/ri3w9nmEw7hvt1wZrxvNa1u4eOzilxPgABXQoNhrixtEGt7z2v PCxg== MIME-Version: 1.0 X-Received: by 10.224.103.66 with SMTP id j2mr33169291qao.66.1384779556898; Mon, 18 Nov 2013 04:59:16 -0800 (PST) In-Reply-To: <528A092D.4060408@chamonix.reportlab.co.uk> References: <5286054F.6000707@chamonix.reportlab.co.uk> <1384539385.17784.47988289.02AE655C@webmail.messagingengine.com> <5289FE6C.7030007@chamonix.reportlab.co.uk> <528A092D.4060408@chamonix.reportlab.co.uk> Date: Mon, 18 Nov 2013 22:59:16 +1000 Subject: Re: [Python-ideas] Unicode stdin/stdout From: Nick Coghlan To: Robin Becker Content-Type: multipart/alternative; boundary=047d7b67001f94cce804eb731dc3 Cc: python-list@python.org, python-ideas@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 74 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384779566 news.xs4all.nl 15989 [2001:888:2000:d::a6]:56379 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59860 --047d7b67001f94cce804eb731dc3 Content-Type: text/plain; charset=ISO-8859-1 On 18 Nov 2013 22:36, "Robin Becker" wrote: > > On 18/11/2013 11:47, Robin Becker wrote: > ........... >> >> #c:\python33\lib\site-packages\sitecustomize.py >> import sys, codecs >> sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) >> sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach()) > > ........ > it seems that the above needs extra stuff to make some distutils logging work etc etc; so now I'm using sitecustomize.py containing > > import sys, codecs > sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) > sys.stdout.encoding = 'utf8' > sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach()) > sys.stderr.encoding = 'utf8' Note that calling detach() on the standard streams isn't officially supported, since it breaks the shadow streams saved in sys.__stderr__, etc. Cheers, Nick. > > -- > Robin Becker > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas --047d7b67001f94cce804eb731dc3 Content-Type: text/html; charset=ISO-8859-1


On 18 Nov 2013 22:36, "Robin Becker" <robin@reportlab.com> wrote:
>
> On 18/11/2013 11:47, Robin Becker wrote:
> ...........
>>
>> #c:\python33\lib\site-packages\sitecustomize.py
>> import sys, codecs
>> sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
>> sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach())
>
> ........
> it seems that the above needs extra stuff to make some distutils logging work etc etc; so now I'm using sitecustomize.py containing
>
> import sys, codecs
> sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
> sys.stdout.encoding = 'utf8'
> sys.stderr = codecs.getwriter("utf-8")(sys.stderr.detach())
> sys.stderr.encoding = 'utf8'

Note that calling detach() on the standard streams isn't officially supported, since it breaks the shadow streams saved in sys.__stderr__, etc.

Cheers,
Nick.

>
> --
> Robin Becker
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas

--047d7b67001f94cce804eb731dc3--