diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2010-06-05 14:30:56 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2010-06-05 14:40:19 -0400 |
commit | 88a2b9047e61c784c2c1e78c3d2434eaaebc8bd0 (patch) | |
tree | 9d52a5c6fcb889899e3baaf86c293f418d1a23e5 | |
parent | 69b9b04d4a1176cc73ce3cc76384af8450434cc2 (diff) | |
download | git-bz-88a2b9047e61c784c2c1e78c3d2434eaaebc8bd0.tar.gz |
Fix problem with stray spaces
Python adds a space character between consecutive calls to
print when the first print doesn't end in a newline. To
avoid problems with this, use <file>.write() rather than
print when:
* We might be printing something empty
* The newline after the line is added via echoed user
input on the terminal
Tracked down by William Jon McCann <william.jon.mccann@gmail.com>
-rwxr-xr-x | git-bz | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -134,8 +134,10 @@ def git_run(command, *args, **kwargs): output, error = process.communicate(input) if process.returncode != 0: if not quiet and not interactive: - print >>sys.stderr, error, - print output, + # Using print here could result in Python adding a stray space + # before the next print + sys.stderr.write(error) + sys.stdout.write(output) raise CalledProcessError(process.returncode, " ".join(to_run)) if interactive: @@ -709,7 +711,9 @@ def expand_abbreviation(abbrev, l): raise ValueError("No unique abbreviation expansion") def prompt(message): - print message, "[yn] ", + # Using print here could result in Python adding a stray space + # before the next print + sys.stdout.write(message + " [yn] ") line = sys.stdin.readline().strip() return line == 'y' or line == 'Y' |