From: John Keeping <john@keeping.me.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Sverre Rabbelier <srabbelier@gmail.com>
Subject: [PATCH v3 7/8] git-remote-testpy: don't do unbuffered text I/O
Date: Sun, 20 Jan 2013 13:15:37 +0000 [thread overview]
Message-ID: <c73b8e6e762bbf19e840994e4ff6e99de465051c.1358686905.git.john@keeping.me.uk> (raw)
In-Reply-To: <cover.1358686905.git.john@keeping.me.uk>
In-Reply-To: <cover.1358686905.git.john@keeping.me.uk>
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>
---
git-remote-testpy.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/git-remote-testpy.py b/git-remote-testpy.py
index 197b7be..5dbf1cc 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)
--
1.8.1.353.gc992d5a.dirty
next prev parent reply other threads:[~2013-01-20 13:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 13:15 [PATCH v3 0/8] Python 3 support for git_remote_helpers John Keeping
2013-01-20 13:15 ` [PATCH v3 1/8] git_remote_helpers: Allow building with Python 3 John Keeping
2013-01-23 18:49 ` Sverre Rabbelier
2013-01-20 13:15 ` [PATCH v3 2/8] git_remote_helpers: fix input when running under " John Keeping
2013-01-23 19:20 ` Sverre Rabbelier
2013-01-23 19:47 ` John Keeping
2013-01-23 20:14 ` Sverre Rabbelier
2013-01-23 20:36 ` Junio C Hamano
2013-01-25 20:23 ` Brandon Casey
2013-02-05 16:07 ` Erik Faye-Lund
2013-01-20 13:15 ` [PATCH v3 3/8] git_remote_helpers: Force rebuild if python version changes John Keeping
2013-01-23 18:51 ` Sverre Rabbelier
2013-01-20 13:15 ` [PATCH v3 4/8] git_remote_helpers: Use 2to3 if building with Python 3 John Keeping
2013-01-20 13:15 ` [PATCH v3 5/8] svn-fe: allow svnrdump_sim.py to run " John Keeping
2013-01-20 13:15 ` [PATCH v3 6/8] git-remote-testpy: hash bytes explicitly John Keeping
2013-01-26 17:51 ` John Keeping
2013-01-26 21:44 ` Junio C Hamano
2013-01-26 23:32 ` [PATCH] git-remote-testpy: fix patch hashing on Python 3 John Keeping
2013-01-27 4:44 ` [PATCH v3 6/8] git-remote-testpy: hash bytes explicitly Michael Haggerty
2013-01-27 5:30 ` Junio C Hamano
2013-01-27 14:21 ` John Keeping
2013-01-27 5:30 ` Sverre Rabbelier
2013-01-27 8:41 ` Michael Haggerty
2013-01-27 14:13 ` John Keeping
2013-01-27 14:50 ` [PATCH] git-remote-testpy: fix patch hashing on Python 3 John Keeping
2013-01-27 19:49 ` Junio C Hamano
2013-01-27 20:04 ` John Keeping
2013-01-27 20:11 ` Junio C Hamano
2013-01-27 20:21 ` John Keeping
2013-01-27 20:38 ` Junio C Hamano
2013-01-27 20:47 ` Junio C Hamano
2013-01-27 22:42 ` John Keeping
2013-01-27 23:18 ` Junio C Hamano
2013-01-28 10:44 ` Michael Haggerty
2013-01-28 11:20 ` [PATCH] fixup! git-remote-testpy: fix path " John Keeping
2013-01-28 17:53 ` Junio C Hamano
2013-01-20 13:15 ` John Keeping [this message]
2013-01-20 13:15 ` [PATCH v3 8/8] git-remote-testpy: call print as a function John Keeping
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c73b8e6e762bbf19e840994e4ff6e99de465051c.1358686905.git.john@keeping.me.uk \
--to=john@keeping.me.uk \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=srabbelier@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).