diff options
author | John Keeping <john@keeping.me.uk> | 2013-01-20 13:15:37 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-24 19:32:35 -0800 |
commit | d04c94a2ea21cb218b43be192d8569c0e669d080 (patch) | |
tree | 734e9f937c584d98b11f427dda9614ea0a6b266f | |
parent | 0846b0c905a885720138e8194fb0289f121b5da1 (diff) | |
download | git-d04c94a2ea21cb218b43be192d8569c0e669d080.tar.gz |
git-remote-testpy: don't do unbuffered text I/O
Python 3 forbids unbuffered I/O in text mode. Change the reading of
stdin in git-remote-testpy so that we read the lines as bytes and then
decode them a line at a time.
This allows us to keep the I/O unbuffered in order to avoid
reintroducing the bug fixed by commit 7fb8e16 (git-remote-testgit: fix
race when spawning fast-import).
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | git-remote-testpy.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/git-remote-testpy.py b/git-remote-testpy.py index 197b7be508..5dbf1cc066 100644 --- a/git-remote-testpy.py +++ b/git-remote-testpy.py @@ -154,7 +154,7 @@ def do_import(repo, args): refs = [ref] while True: - line = sys.stdin.readline() + line = sys.stdin.readline().decode() if line == '\n': break if not line.startswith('import '): @@ -225,7 +225,7 @@ def read_one_line(repo): line = sys.stdin.readline() - cmdline = line + cmdline = line.decode() if not cmdline: warn("Unexpected EOF") @@ -277,7 +277,11 @@ def main(args): more = True - sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0) + # Use binary mode since Python 3 does not permit unbuffered I/O in text + # mode. Unbuffered I/O is required to avoid data that should be going + # to git-fast-import after an "export" command getting caught in our + # stdin buffer instead. + sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0) while (more): more = read_one_line(repo) |