You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by bo...@apache.org on 2022/03/07 16:15:29 UTC

[impala] 02/02: IMPALA-11133 (Addendum): Encode a string in utf8 before printing it

This is an automated email from the ASF dual-hosted git repository.

boroknagyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 7450c96a76d81e21b2758d0bc5dcb673a6198d65
Author: Fang-Yu Rao <fa...@cloudera.com>
AuthorDate: Wed Feb 23 15:53:39 2022 -0800

    IMPALA-11133 (Addendum): Encode a string in utf8 before printing it
    
    In the first part of this patch, we decoded a string with 'utf8' in
    order to print it (on the command line) since the author field of a
    commit could contain non-ASCII characters.
    
    However, we did not take into consideration that in some scenarios,
    we would like to redirect the output to another file. If this is the
    case, then we may encounter a UnicodeEncodeError due to
    sys.stdout.encoding being None. To resolve the issue, we encode the
    formatted string with 'utf8'.
    
    Testing:
     - Manually verified that we won't get a UnicodeEncodeError if we
       redirect the output to another file.
    
    Change-Id: Iad9b1fb0a523e219bc9f40a57ff7335808be283f
    Reviewed-on: http://gerrit.cloudera.org:8080/18270
    Reviewed-by: Quanlong Huang <hu...@gmail.com>
    Tested-by: Quanlong Huang <hu...@gmail.com>
---
 bin/compare_branches.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/compare_branches.py b/bin/compare_branches.py
index 4027974..da1d5f8 100755
--- a/bin/compare_branches.py
+++ b/bin/compare_branches.py
@@ -268,7 +268,8 @@ def main():
                    .format(commit_hash, options.source_branch, options.target_branch))
     if not change_in_target and not ignore_by_config and not ignore_by_commit_message:
       print u'{0} {1} ({2}) - {3}'\
-          .format(commit_hash, msg.decode('utf8'), date, author.decode('utf8'))
+          .format(commit_hash, msg.decode('utf8'), date, author.decode('utf8'))\
+          .encode('utf8')
       cherry_pick_hashes.append(commit_hash)
       jira_keys += jira_key_pat.findall(msg)