From 45d1c372a79fe35e1deb4956708432bc9ae80ea0 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 11 Feb 2020 03:35:24 -0500 Subject: 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 (cherry picked from commit 163d42eb43ba79677aae22fa859896010badba9b) --- project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'project.py') diff --git a/project.py b/project.py index 281ba4b7..77b97f73 100644 --- a/project.py +++ b/project.py @@ -1989,7 +1989,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, -- cgit v1.2.3-54-g00ecf