Enable 'elaborate line editing' in `gclient_utils.AskForData`

The (raw_)input Python function used by `gclient_utils.AskForData`
supports additional 'elaborate line editing' [1] [2] features, such as
the ability to use backspace to fix a typo, if the readline module is
loaded. Make sure that readline is loaded by importing it locally in
`gclient_utils.AskForData`.
It does not appear to be possible to write a test that verifies this
behavior - assigning `io.StringIO` to `sys.stdin` appears to cause
(raw_)input to fall back to basic input processing.

[1] https://docs.python.org/2.7/library/functions.html#raw_input
[2] https://docs.python.org/3/library/functions.html#input

Change-Id: Ie1c25b3fa2f3a255b78426c20e47c968cd7198ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3306613
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Christian Flach <cmfcmf@chromium.org>
diff --git a/gclient_utils.py b/gclient_utils.py
index b645806..ae958cd 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -160,6 +160,15 @@
 
 
 def AskForData(message):
+  # Try to load the readline module, so that "elaborate line editing" features
+  # such as backspace work for `raw_input` / `input`.
+  try:
+    import readline
+  except ImportError:
+    # The readline module does not exist in all Python distributions, e.g. on
+    # Windows. Fall back to simple input handling.
+    pass
+
   # Use this so that it can be mocked in tests on Python 2 and 3.
   try:
     if sys.version_info.major == 2: