From 163d42eb43ba79677aae22fa859896010badba9b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 11 Feb 2020 03:35:24 -0500 Subject: [PATCH] project: fix bytes/str encoding when updating git submodules Since tempfile.mkstemp() returns a file handle in binary mode, make sure we turn our strings into bytes before writing. Bug: https://crbug.com/gerrit/12043 Change-Id: I3e84d595e84b8bc12a1fbc7fd0bb3ea0ba2832b0 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254393 Reviewed-by: Michael Mortensen Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.py b/project.py index a305d720..0e047f8a 100644 --- a/project.py +++ b/project.py @@ -2073,7 +2073,7 @@ class Project(object): gitmodules_lines = [] fd, temp_gitmodules_path = tempfile.mkstemp() try: - os.write(fd, p.stdout) + os.write(fd, p.stdout.encode('utf-8')) os.close(fd) cmd = ['config', '--file', temp_gitmodules_path, '--list'] p = GitCommand(None, cmd, capture_stdout=True, capture_stderr=True,