Python Debugger: fixed an issue related to redirecting the input() builtin function.

Thu, 23 Apr 2020 18:50:54 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 23 Apr 2020 18:50:54 +0200
changeset 7550
e91462fd0838
parent 7549
fcfbb9e94471
child 7551
b159c55ea6dd

Python Debugger: fixed an issue related to redirecting the input() builtin function.

eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/getpass.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugClientBase.py	Wed Apr 22 19:58:01 2020 +0200
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Thu Apr 23 18:50:54 2020 +0200
@@ -44,13 +44,17 @@
 
 def DebugClientRawInput(prompt="", echo=True):
     """
-    Replacement for the standard raw_input builtin.
+    Replacement for the standard raw_input() builtin (Python 2) and
+    the standard input() builtin (Python 3).
     
     This function works with the split debugger.
     
-    @param prompt prompt to be shown. (string)
-    @param echo flag indicating echoing of the input (boolean)
-    @return result of the raw_input() call
+    @param prompt prompt to be shown
+    @type str
+    @param echo flag indicating echoing of the input
+    @type bool
+    @return result of the raw_input()/input() call
+    @rtype str
     """
     if DebugClientInstance is None or not DebugClientInstance.redirect:
         return DebugClientOrigRawInput(prompt)
@@ -58,20 +62,21 @@
     return DebugClientInstance.raw_input(prompt, echo)
 
 
-def DebugClientInput(prompt="", echo=True):
+def DebugClientInput(prompt=""):
     """
-    Replacement for the standard input builtin.
+    Replacement for the standard input() builtin (Python 2).
     
     This function works with the split debugger.
     
-    @param prompt prompt to be shown (string)
-    @param echo flag indicating to echo the output (boolean)
+    @param prompt prompt to be shown 
+    @type str
     @return result of the input() call
+    @rtype str
     """
     if DebugClientInstance is None or not DebugClientInstance.redirect:
         return DebugClientOrigInput(prompt)
 
-    return DebugClientInstance.input(prompt, echo)
+    return DebugClientInstance.input(prompt)
 
 # Use our own input() and on Python 2 raw_input().
 if sys.version_info[0] == 2:
@@ -93,11 +98,11 @@
 else:
     try:
         DebugClientOrigInput = __builtins__.__dict__['input']
-        __builtins__.__dict__['input'] = DebugClientInput
+        __builtins__.__dict__['input'] = DebugClientRawInput
     except (AttributeError, KeyError):
         import __main__
         DebugClientOrigInput = __main__.__builtins__.__dict__['input']
-        __main__.__builtins__.__dict__['input'] = DebugClientInput
+        __main__.__builtins__.__dict__['input'] = DebugClientRawInput
 
 ###############################################################################
 
--- a/eric6/DebugClients/Python/getpass.py	Wed Apr 22 19:58:01 2020 +0200
+++ b/eric6/DebugClients/Python/getpass.py	Thu Apr 23 18:50:54 2020 +0200
@@ -23,7 +23,8 @@
     First try various environment variables, then the password
     database.  This works on Windows as long as USERNAME is set.
     
-    @return username (string)
+    @return username
+    @rtype str
     """
     # this is copied from the oroginal getpass.py
     
@@ -43,8 +44,10 @@
     """
     Function to prompt for a password, with echo turned off.
     
-    @param prompt Prompt to be shown to the user (string)
-    @return Password entered by the user (string)
+    @param prompt Prompt to be shown to the user
+    @type str
+    @return Password entered by the user
+    @rtype str
     """
     return input(prompt, False)
     
@@ -52,6 +55,7 @@
 unix_getpass = getpass
 win_getpass = getpass
 default_getpass = getpass
+fallback_getpass = getpass
 
 #
 # eflag: noqa = M702

eric ide

mercurial