diff options
author | Mike Frysinger <vapier@google.com> | 2019-07-04 17:35:11 -0400 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-07-11 06:26:40 +0000 |
commit | ab85fe7c535bfa97c067354d8a23e39b849f6728 (patch) | |
tree | 3de17ed8b68af5cef82eaf5553ca3de41bd7e955 /subcmds/upload.py | |
parent | 4f42a9706715c9c5add46632343f7108aabcd530 (diff) | |
download | git-repo-ab85fe7c535bfa97c067354d8a23e39b849f6728.tar.gz |
use print() instead of sys.stdout.write()
We're relying on sys.stdout.write() to flush its buffer which isn't
guaranteed, and is not the case in Python 3. Change to use print()
everywhere to be standard, and utilize the end= keyword to get the
EOL semantics we need.
We can't use print's flush= keyword as that's only in Python 3.
Leave behind a TODO to clean it up when we can drop Python 2.
Bug: https://crbug.com/gerrit/10418
Change-Id: I562128c7f1e6d154f4a6ecdf33a70fa2811dc2af
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/230392
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r-- | subcmds/upload.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index e7e5b1bf..d0dd3837 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -221,7 +221,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
221 | for commit in commit_list: | 221 | for commit in commit_list: |
222 | print(' %s' % commit) | 222 | print(' %s' % commit) |
223 | 223 | ||
224 | sys.stdout.write('to %s (y/N)? ' % remote.review) | 224 | print('to %s (y/N)? ' % remote.review, end='') |
225 | # TODO: When we require Python 3, use flush=True w/print above. | ||
226 | sys.stdout.flush() | ||
225 | answer = sys.stdin.readline().strip().lower() | 227 | answer = sys.stdin.readline().strip().lower() |
226 | answer = answer in ('y', 'yes', '1', 'true', 't') | 228 | answer = answer in ('y', 'yes', '1', 'true', 't') |
227 | 229 | ||
@@ -360,10 +362,13 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
360 | 362 | ||
361 | # if they want to auto upload, let's not ask because it could be automated | 363 | # if they want to auto upload, let's not ask because it could be automated |
362 | if answer is None: | 364 | if answer is None: |
363 | sys.stdout.write('Uncommitted changes in ' + branch.project.name) | 365 | print() |
364 | sys.stdout.write(' (did you forget to amend?):\n') | 366 | print('Uncommitted changes in %s (did you forget to amend?):' |
365 | sys.stdout.write('\n'.join(changes) + '\n') | 367 | % branch.project.name) |
366 | sys.stdout.write('Continue uploading? (y/N) ') | 368 | print('\n'.join(changes)) |
369 | print('Continue uploading? (y/N) ', end='') | ||
370 | # TODO: When we require Python 3, use flush=True w/print above. | ||
371 | sys.stdout.flush() | ||
367 | a = sys.stdin.readline().strip().lower() | 372 | a = sys.stdin.readline().strip().lower() |
368 | if a not in ('y', 'yes', 't', 'true', 'on'): | 373 | if a not in ('y', 'yes', 't', 'true', 'on'): |
369 | print("skipping upload", file=sys.stderr) | 374 | print("skipping upload", file=sys.stderr) |