Skip to content

Commit 7575f4f

Browse files
yangskyboxlabsgitster
authored andcommitted
git-p4: use python3's input() everywhere
Python3 deprecates raw_input() from 2.7 and replaced it with input(). Since we do not need 2.7's input() semantics, `raw_input()` is aliased to `input()` for easy forward compatability. Signed-off-by: Yang Zhao <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce425eb commit 7575f4f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

git-p4.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
import ctypes
2828
import errno
2929

30+
# On python2.7 where raw_input() and input() are both availble,
31+
# we want raw_input's semantics, but aliased to input for python3
32+
# compatibility
33+
# support basestring in python3
34+
try:
35+
if raw_input and input:
36+
input = raw_input
37+
except:
38+
pass
39+
3040
verbose = False
3141

3242
# Only labels/tags matching this will be imported/exported
@@ -1801,7 +1811,7 @@ def edit_template(self, template_file):
18011811
return True
18021812

18031813
while True:
1804-
response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
1814+
response = input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
18051815
if response == 'y':
18061816
return True
18071817
if response == 'n':
@@ -2372,7 +2382,7 @@ def run(self, args):
23722382
# prompt for what to do, or use the option/variable
23732383
if self.conflict_behavior == "ask":
23742384
print("What do you want to do?")
2375-
response = raw_input("[s]kip this commit but apply"
2385+
response = input("[s]kip this commit but apply"
23762386
" the rest, or [q]uit? ")
23772387
if not response:
23782388
continue

0 commit comments

Comments
 (0)