Fix critical crash when running on non utf-8 environment.
Review Request #7395 — Created June 8, 2015 and submitted
When running on non UTF-8 environment with mercurial as repository RBTools crashes for every command with message:
'CRITICAL: 'utf8' codec can't decode byte 0xb3 in position 22: invalid start byte.'. This is caused by assumption in process.py execute method.Now we are using sys.getfilesystemencoding() instead of assumpted 'utf-8'.
Running on non UTF-8 environment (Win7, x64 PL) does not cause error anymore.
-
Mind reworking the description into more of the format described here? https://www.reviewboard.org/docs/codebase/dev/writing-good-descriptions/
That will help with getting a thorough understanding of the problem, its cause, its fix, and why the fix works. It will also help when bisecting commits later, and with preparation of release notes. -
- Summary:
-
Avoid assuming utf-8 encoding of external command std output.Fix critical crash when running on non utf-8 environment.
- Description:
-
~ In my system (win 7 x64 PL) when invoking:
~ for line in execute(['hg', 'showconfig'], split_lines=True): ~ When running on non UTF-8 environment with mercurial as repository RBTools crashes for every command with message:
~ 'CRITICAL: 'utf8' codec can't decode byte 0xb3 in position 22: invalid start byte.'. This is caused by assumption in process.py execute method. ~ I was getting:
~ Now we are using sys.getfilesystemencoding() instead of assumpted 'utf-8'.
- CRITICAL: 'utf8' codec can't decode byte 0xb3 in position 22: invalid start byte. - - Fix: Using sys.getfilesystemencoding() instead if 'utf-8'
- Testing Done:
-
~ "CRITICAL: 'utf8' codec can't decode byte 0xb3 in position 22: invalid start byte." not appearing for 'rbt diff'
~ Running on non UTF-8 environment (Win7, x64 PL) does not cause error anymore.
-
Tool: Pyflakes Processed Files: rbtools/utils/process.py Tool: PEP8 Style Checker Processed Files: rbtools/utils/process.py