remi        14/08/17 23:03:09

  Added:               
                        
intel-gpu-tools-1.7-shader-debugger-Force-file-stdout-IO-as-UTF-8.patch
  Log:
  x11-apps/intel-gpu-tools: Fix python script to handle non-UTF-8 locales
  
  (Portage version: 2.2.12/cvs/Linux x86_64, unsigned Manifest commit)

Revision  Changes    Path
1.1                  
x11-apps/intel-gpu-tools/files/intel-gpu-tools-1.7-shader-debugger-Force-file-stdout-IO-as-UTF-8.patch

file : 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-apps/intel-gpu-tools/files/intel-gpu-tools-1.7-shader-debugger-Force-file-stdout-IO-as-UTF-8.patch?rev=1.1&view=markup
plain: 
http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-apps/intel-gpu-tools/files/intel-gpu-tools-1.7-shader-debugger-Force-file-stdout-IO-as-UTF-8.patch?rev=1.1&content-type=text/plain

Index: intel-gpu-tools-1.7-shader-debugger-Force-file-stdout-IO-as-UTF-8.patch
===================================================================
>From e9e9df216180bcecc5d4c17bbe48b2efd88b3ed2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Cardona?= <r...@gentoo.org>
Date: Mon, 18 Aug 2014 00:44:32 +0200
Subject: [PATCH] shader-debugger: Force file/stdout IO as UTF-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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=519434
Signed-off-by: RĂ©mi Cardona <r...@gentoo.org>
---
 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 = open(sys.argv[1], "r")
+# make sure both input file and stdout are handled as utf-8 text, regardless
+# of current locale (eg. LANG=C which tells python to use ascii encoding)
+sys.stdout = open(sys.__stdout__.fileno(), "a", encoding="utf-8")
+file = open(sys.argv[1], "r", encoding="utf-8")
 
 lines = file.readlines()
 len(lines)
-- 
2.0.4





Reply via email to