Skip to content

Commit 2ec3265

Browse files
srowenHyukjinKwon
authored andcommitted
[MINOR][BUILD] Decode output of commands during merge script as UTF-8 consistently
### What changes were proposed in this pull request? In the PR merge script, decode the raw output of subprocess commands like `git` using UTF-8 encoding, consistently. ### Why are the changes needed? The merge script occasionally fails if run with Python 2 and the output of a command like `git` contains non-ASCII characters. I think this most usually happens when a user name, for example, contains Chinese characters. This is because the output is decoded according to `sys.getdefaultencoding()`, which is ASCII in Python 2. It's UTF-8 in Python 3, by default. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? The change caused a merge that failed before to succeed. Closes #25991 from srowen/MergePRUTF8. Authored-by: Sean Owen <[email protected]> Signed-off-by: HyukjinKwon <[email protected]>
1 parent e138801 commit 2ec3265

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dev/merge_spark_pr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ def fail(msg):
9797
def run_cmd(cmd):
9898
print(cmd)
9999
if isinstance(cmd, list):
100-
return subprocess.check_output(cmd).decode(sys.getdefaultencoding())
100+
return subprocess.check_output(cmd).decode('utf-8')
101101
else:
102-
return subprocess.check_output(cmd.split(" ")).decode(sys.getdefaultencoding())
102+
return subprocess.check_output(cmd.split(" ")).decode('utf-8')
103103

104104

105105
def continue_maybe(prompt):

0 commit comments

Comments
 (0)