Fix UnicodeDecodeError when commit message contains non-ascii character

Review Request #10121 — Created Aug. 15, 2018 and updated

fangwentong
RBTools
master
6526243...
rbtools

subprocess output data is str type, convert it to unicode when results_unicode is true

  • Posted some changes.
  • Ran unit tests.
  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

fangwentong
fangwentong
fangwentong
fangwentong
fangwentong
fangwentong
fangwentong
fangwentong
Review request changed

Commit:

-ada54f6934d45141d23ddd35c6e00330f619d5a1
+652624311195820212f58fa5a638d6ddabbc8e73

Diff:

Revision 7 (+4 -1)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
david
  1. 
      
  2. When results_unicode is True, subprocess is called with universal_newlines=True. In this case, it should return results as unicode instead of bytes. Is there a particular case you're seeing where this isn't working?

    1. Yes, I tested this on MacOS and ubuntu with python2.7, subprocess.communicate() returns str instead of unicode.

      when commit message contains non-ascii character, rbt post --stamp will raise UnicodeDecodeError and fail add stamp to commit message.

      see the test case in diff 6: https://reviews.reviewboard.org/r/10121/diff/6/. this testcase cause flake8 internal error, so I remove the testcase in diff 7

    2. When commit message contains non-ascii character, rbt post -r will fail and prompt UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128).

      Modification in rbtools/utils/console.py fixed this problem.

  3. 
      
Loading...