From 88a2b9047e61c784c2c1e78c3d2434eaaebc8bd0 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Sat, 5 Jun 2010 14:30:56 -0400 Subject: 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 .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 --- git-bz | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/git-bz b/git-bz index 9fa4890..b73fe52 100755 --- a/git-bz +++ b/git-bz @@ -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' -- cgit v1.2.3