Change print statements to work in python3
This is part of a series of changes to introduce Python3 support.
Change-Id: I373be5de7141aa127d7debdbce1df39148dbec32
diff --git a/subcmds/cherry_pick.py b/subcmds/cherry_pick.py
index 7a6d4c2..0cefec1 100644
--- a/subcmds/cherry_pick.py
+++ b/subcmds/cherry_pick.py
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
import re
import sys
from command import Command
@@ -46,13 +47,13 @@
capture_stdout = True,
capture_stderr = True)
if p.Wait() != 0:
- print >>sys.stderr, p.stderr
+ print(p.stderr, file=sys.stderr)
sys.exit(1)
sha1 = p.stdout.strip()
p = GitCommand(None, ['cat-file', 'commit', sha1], capture_stdout=True)
if p.Wait() != 0:
- print >>sys.stderr, "error: Failed to retrieve old commit message"
+ print("error: Failed to retrieve old commit message", file=sys.stderr)
sys.exit(1)
old_msg = self._StripHeader(p.stdout)
@@ -62,8 +63,8 @@
capture_stderr = True)
status = p.Wait()
- print >>sys.stdout, p.stdout
- print >>sys.stderr, p.stderr
+ print(p.stdout, file=sys.stdout)
+ print(p.stderr, file=sys.stderr)
if status == 0:
# The cherry-pick was applied correctly. We just need to edit the
@@ -76,16 +77,14 @@
capture_stderr = True)
p.stdin.write(new_msg)
if p.Wait() != 0:
- print >>sys.stderr, "error: Failed to update commit message"
+ print("error: Failed to update commit message", file=sys.stderr)
sys.exit(1)
else:
- print >>sys.stderr, """\
-NOTE: When committing (please see above) and editing the commit message,
-please remove the old Change-Id-line and add:
-"""
- print >>sys.stderr, self._GetReference(sha1)
- print >>sys.stderr
+ print('NOTE: When committing (please see above) and editing the commit'
+ 'message, please remove the old Change-Id-line and add:')
+ print(self._GetReference(sha1), file=stderr)
+ print(file=stderr)
def _IsChangeId(self, line):
return CHANGE_ID_RE.match(line)