Skip to contentSkip to conversation

shader-debugger: Force file/stdout IO as UTF-8

PATCH In review Rémi Cardona 2 participants 3 messages Aug 17, 2014 – Aug 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shader-debugger: Force file/stdout IO as UTF-8

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

---
 debugger/system_routine/pre_cpp.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
debugger/system_routine/pre_cpp.py +4 -1
index effea0e..584d2af 100755
@@ -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)
Signature · 6 lines
2.0.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 6 lines · Rémi Cardona

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

Ping ?

Rémi
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Rémi Cardona
Quoted 6 lines · Rémi Cardona

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

Looks reasonable, pushed, thanks for the patch.

Signature · 1 line
Damien
Quoted 27 lines
---
 debugger/system_routine/pre_cpp.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
debugger/system_routine/pre_cpp.py +4 -1
index effea0e..584d2af 100755
@@ -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)
Signature · 6 lines
2.0.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx