summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kutik <daniel.kutik@lavawerk.com>2023-10-09 13:21:25 +0200
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-10-09 17:04:38 +0000
commit6a7f73bb9a55ab4463238af4c5096e6bf3789934 (patch)
tree6c21d19062ffffc5e2918f6dbb0c6d246abf2b17
parent23d063bdcd1bdcaa70ac8565615764dd4313adf9 (diff)
downloadgit-repo-6a7f73bb9a55ab4463238af4c5096e6bf3789934.tar.gz
git_command: read1 needs a size in py3.6
Not setting size causes "TypeError: read1() takes exactly one argument (0 given)" in Python 3.6. In Python 3.7 onwards size defaults to -1, which means an arbitrary number of bytes will be returned. Compare https://docs.python.org/3.6/library/io.html#io.BufferedReader.read1 and https://docs.python.org/3.7/library/io.html#io.BufferedIOBase.read1 for more details. Change-Id: Ia4aaf8140ead9493ec650fac167c641569e6a9d8 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/388718 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com> Commit-Queue: Daniel Kutik <daniel.kutik@lavawerk.com>
-rw-r--r--git_command.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/git_command.py b/git_command.py
index 4b17f78d..2e4974fa 100644
--- a/git_command.py
+++ b/git_command.py
@@ -503,7 +503,8 @@ class GitCommand(object):
503 A str containing everything read from the in_stream. 503 A str containing everything read from the in_stream.
504 """ 504 """
505 buffer = "" 505 buffer = ""
506 chunk = in_stream.read1() 506 read_size = 1024 if sys.version_info < (3, 7) else -1
507 chunk = in_stream.read1(read_size)
507 while chunk: 508 while chunk:
508 # Convert to str. 509 # Convert to str.
509 if not hasattr(chunk, "encode"): 510 if not hasattr(chunk, "encode"):
@@ -513,7 +514,7 @@ class GitCommand(object):
513 out_stream.write(chunk) 514 out_stream.write(chunk)
514 out_stream.flush() 515 out_stream.flush()
515 516
516 chunk = in_stream.read1() 517 chunk = in_stream.read1(read_size)
517 518
518 return buffer 519 return buffer
519 520