summaryrefslogtreecommitdiffstats
path: root/repo
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-05-17 10:49:33 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-05-23 07:28:53 +0000
commit59bbb580e34bbc5dce76dacaad9ff94f21fa396f (patch)
tree4d19216215edc174851baa10a00a3bccba9d4e45 /repo
parentda45e5d8848246cddbce80ff56786bd7330ba5af (diff)
downloadgit-repo-59bbb580e34bbc5dce76dacaad9ff94f21fa396f.tar.gz
Move Python version checking to a separate module
Add a new module with methods for checking the Python version. Instead of handling Python3 imports with try...except blocks, first check the python version and then import the relevant modules. This makes the code a bit cleaner and will result in less diff when/if we remove support for Python < 3 later. Use the same mechanism to handle `input` vs. `raw_input` and add suppression of pylint warnings caused by redefinition of the built-in method `input`. Change-Id: Ia403e525b88d77640a741ac50382146e7d635924 Also-by: Chirayu Desai <cdesai@cyanogenmod.org> Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
Diffstat (limited to 'repo')
-rwxr-xr-xrepo8
1 files changed, 3 insertions, 5 deletions
diff --git a/repo b/repo
index 791e40cb..58e82fe7 100755
--- a/repo
+++ b/repo
@@ -117,15 +117,13 @@ import re
117import stat 117import stat
118import subprocess 118import subprocess
119import sys 119import sys
120try: 120
121 import urllib2 121if sys.version_info[0] == 3:
122except ImportError:
123 # For python3
124 import urllib.request 122 import urllib.request
125 import urllib.error 123 import urllib.error
126else: 124else:
127 # For python2
128 import imp 125 import imp
126 import urllib2
129 urllib = imp.new_module('urllib') 127 urllib = imp.new_module('urllib')
130 urllib.request = urllib2 128 urllib.request = urllib2
131 urllib.error = urllib2 129 urllib.error = urllib2