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 <yang.zhao@skyboxlabs.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Yang Zhao committed
Dec 13, 2019 at 15:52 UTC
7575f4fdecf22cf232975625ec53add3f2b962e4
1 file changed
+12
-2
git-p4.py
+12
-2
@@ -27,6 +27,16 @@ import zlib
27
import ctypes
28
import errno
29
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
+
40
verbose = False
41
42
# Only labels/tags matching this will be imported/exported
@@ -1801,7 +1811,7 @@ class P4Submit(Command, P4UserMap):
1811
return True
1812
1813
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) ")
1815
if response == 'y':
1816
return True
1817
if response == 'n':
@@ -2372,7 +2382,7 @@ class P4Submit(Command, P4UserMap):
2382
# prompt for what to do, or use the option/variable
2383
if self.conflict_behavior == "ask":
2384
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"
2386
" the rest, or [q]uit? ")
2387
if not response:
2388
continue