From: Damien Lespiau Subject: Re: [PATCH] shader-debugger: Force file/stdout IO as UTF-8 Date: Wed, 27 Aug 2014 08:56:48 +0100 Message-ID: <20140827075648.GE6174@strange.amr.corp.intel.com> References: <1408316955-18073-1-git-send-email-remi@gentoo.org> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id D916589C89 for ; Wed, 27 Aug 2014 00:56:58 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1408316955-18073-1-git-send-email-remi@gentoo.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: =?iso-8859-1?Q?R=E9mi?= Cardona Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Mon, Aug 18, 2014 at 01:09:15AM +0200, R=E9mi Cardona wrote: > Not all locales on linux are UTF-8, the most notable being the C locale. > Python will use the ASCII codec for stream IO in this case and will barf > on the Copyright sign at the top of .g4a files. > = > Bugzilla: https://bugs.gentoo.org/show_bug.cgi?id=3D519434 > Signed-off-by: R=E9mi Cardona Looks reasonable, pushed, thanks for the patch. -- = Damien > --- > debugger/system_routine/pre_cpp.py | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > = > diff --git a/debugger/system_routine/pre_cpp.py b/debugger/system_routine= /pre_cpp.py > index effea0e..584d2af 100755 > --- a/debugger/system_routine/pre_cpp.py > +++ b/debugger/system_routine/pre_cpp.py > @@ -33,7 +33,10 @@ > = > import sys,re > = > -file =3D open(sys.argv[1], "r") > +# make sure both input file and stdout are handled as utf-8 text, regard= less > +# of current locale (eg. LANG=3DC which tells python to use ascii encodi= ng) > +sys.stdout =3D open(sys.__stdout__.fileno(), "a", encoding=3D"utf-8") > +file =3D open(sys.argv[1], "r", encoding=3D"utf-8") > = > lines =3D file.readlines() > len(lines) > -- = > 2.0.4 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx