From 63a5657ecfe1585ceda3231bfe8a6c8d9c3dafad Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 19 Aug 2022 02:11:35 -0400 Subject: [PATCH] git_command: fix input passing After reworking this function to use subprocess for output capturing in commit c87c1863b1df392042c8859b81475a65315c8a9d ("git_command: switch process capturing over to subprocess"), passing input via stdin write no longer works. We have to pass it via communicate(), and we have to pass it a string instead of bytes (since we always use encoding='utf-8' now). This is fine since the only user of the input= setting today is already passing in a string. Bug: https://crbug.com/gerrit/16151 Change-Id: Ic58db1e568b8f8aa840a6d62c5a157c14aa6d9bc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/343515 Tested-by: Mike Frysinger Reviewed-by: LaMont Jones --- git_command.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/git_command.py b/git_command.py index a1769270..19100fa9 100644 --- a/git_command.py +++ b/git_command.py @@ -281,14 +281,9 @@ class GitCommand(object): ssh_proxy.add_client(p) self.process = p - if input: - if isinstance(input, str): - input = input.encode('utf-8') - p.stdin.write(input) - p.stdin.close() try: - self.stdout, self.stderr = p.communicate() + self.stdout, self.stderr = p.communicate(input=input) finally: if ssh_proxy: ssh_proxy.remove_client(p)