Bug 80734

Summary: [igt] intel-gpu-tools/debugger/system_routine only builds in UTF-8 locales
Product: DRI Reporter: Adam Sampson <ats-fd>
Component: DRM/IntelAssignee: Intel GFX Bugs mailing list <intel-gfx-bugs>
Status: CLOSED FIXED QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: minor    
Priority: medium CC: intel-gfx-bugs
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Specify the encoding explicitly none

Description Adam Sampson 2014-06-30 22:19:20 UTC
Created attachment 102034 [details]
Specify the encoding explicitly

If you try to compile intel-gpu-tools 1.7 in the C locale, where the default encoding is ASCII, you'll get this error:

make[5]: Entering directory '/src/xorg/intel-gpu-tools/work/intel-gpu-tools-1.7/
debugger/system_routine'
./pre_cpp.py ./sr.g4a > sr.cpp.tmp && mv sr.cpp.tmp sr.cpp
Traceback (most recent call last):
  File "./pre_cpp.py", line 38, in <module>
    lines = file.readlines()
  File "/gar/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 16: ordinal not in range(128)

That's because pre_cpp.py is a Python 3 program, and it's just called open() on the file, which contains a UTF-8-encoded copyright symbol, without specifying an encoding. In that case, Python 3 defaults to whatever the locale's encoding is, so this'll work if your locale's encoding is UTF-8, but will either crash or misinterpret the file if not.

One fix is to explicitly specify the encoding when opening the file. Patch attached.
Comment 1 Jani Nikula 2014-07-01 09:30:42 UTC
$ git shortlog -s -- debugger/system_routine/pre_cpp.py
     1  Ben Widawsky
Comment 2 Damien Lespiau 2014-09-18 13:04:55 UTC
Missed this one entirely in the noise, but I recently merged a fix for this issue.

http://cgit.freedesktop.org/xorg/app/intel-gpu-tools/commit/debugger?id=2ef19ad79a07d862a2dc799ab2e71d2ad91c9065

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.