git-p4: python3: basestring workaround
authorLuke Diamand <luke@diamand.org>
Tue, 19 Jun 2018 08:04:09 +0000 (09:04 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Jun 2018 16:34:32 +0000 (09:34 -0700)
In Python3, basestring no longer exists, so use this workaround.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py
index 67865d14aa62896794827264c149232b8ab8b68b..f127ebce276947d879b2965eb94b79f68528b0e2 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
 import ctypes
 import errno
 
+# support basestring in python3
+try:
+    unicode = unicode
+except NameError:
+    # 'unicode' is undefined, must be Python 3
+    str = str
+    unicode = str
+    bytes = bytes
+    basestring = (str,bytes)
+else:
+    # 'unicode' exists, must be Python 2
+    str = str
+    unicode = unicode
+    bytes = str
+    basestring = basestring
+
 try:
     from subprocess import CalledProcessError
 except ImportError: