summaryrefslogtreecommitdiffstats
path: root/git_config.py
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 /git_config.py
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 'git_config.py')
-rw-r--r--git_config.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/git_config.py b/git_config.py
index 9524df9b..431cd457 100644
--- a/git_config.py
+++ b/git_config.py
@@ -25,14 +25,13 @@ try:
25except ImportError: 25except ImportError:
26 import dummy_threading as _threading 26 import dummy_threading as _threading
27import time 27import time
28try: 28
29 import urllib2 29from pyversion import is_python3
30except ImportError: 30if is_python3():
31 # For python3
32 import urllib.request 31 import urllib.request
33 import urllib.error 32 import urllib.error
34else: 33else:
35 # For python2 34 import urllib2
36 import imp 35 import imp
37 urllib = imp.new_module('urllib') 36 urllib = imp.new_module('urllib')
38 urllib.request = urllib2 37 urllib.request = urllib2