46 ############################################################################### |
46 ############################################################################### |
47 |
47 |
48 |
48 |
49 def DebugClientRawInput(prompt="", echo=True): |
49 def DebugClientRawInput(prompt="", echo=True): |
50 """ |
50 """ |
51 Replacement for the standard raw_input builtin. |
51 Replacement for the standard raw_input() builtin (Python 2) and |
|
52 the standard input() builtin (Python 3). |
52 |
53 |
53 This function works with the split debugger. |
54 This function works with the split debugger. |
54 |
55 |
55 @param prompt prompt to be shown. (string) |
56 @param prompt prompt to be shown |
56 @param echo flag indicating echoing of the input (boolean) |
57 @type str |
57 @return result of the raw_input() call |
58 @param echo flag indicating echoing of the input |
|
59 @type bool |
|
60 @return result of the raw_input()/input() call |
|
61 @rtype str |
58 """ |
62 """ |
59 if DebugClientInstance is None or not DebugClientInstance.redirect: |
63 if DebugClientInstance is None or not DebugClientInstance.redirect: |
60 return DebugClientOrigRawInput(prompt) |
64 return DebugClientOrigRawInput(prompt) |
61 |
65 |
62 return DebugClientInstance.raw_input(prompt, echo) |
66 return DebugClientInstance.raw_input(prompt, echo) |
63 |
67 |
64 |
68 |
65 def DebugClientInput(prompt="", echo=True): |
69 def DebugClientInput(prompt=""): |
66 """ |
70 """ |
67 Replacement for the standard input builtin. |
71 Replacement for the standard input() builtin (Python 2). |
68 |
72 |
69 This function works with the split debugger. |
73 This function works with the split debugger. |
70 |
74 |
71 @param prompt prompt to be shown (string) |
75 @param prompt prompt to be shown |
72 @param echo flag indicating to echo the output (boolean) |
76 @type str |
73 @return result of the input() call |
77 @return result of the input() call |
|
78 @rtype str |
74 """ |
79 """ |
75 if DebugClientInstance is None or not DebugClientInstance.redirect: |
80 if DebugClientInstance is None or not DebugClientInstance.redirect: |
76 return DebugClientOrigInput(prompt) |
81 return DebugClientOrigInput(prompt) |
77 |
82 |
78 return DebugClientInstance.input(prompt, echo) |
83 return DebugClientInstance.input(prompt) |
79 |
84 |
80 # Use our own input() and on Python 2 raw_input(). |
85 # Use our own input() and on Python 2 raw_input(). |
81 if sys.version_info[0] == 2: |
86 if sys.version_info[0] == 2: |
82 try: |
87 try: |
83 DebugClientOrigRawInput = __builtins__.__dict__['raw_input'] |
88 DebugClientOrigRawInput = __builtins__.__dict__['raw_input'] |
103 except (AttributeError, KeyError): |
108 except (AttributeError, KeyError): |
104 DebugClientOrigInput = lambda x: '' # __IGNORE_WARNING__ |
109 DebugClientOrigInput = lambda x: '' # __IGNORE_WARNING__ |
105 else: |
110 else: |
106 try: |
111 try: |
107 DebugClientOrigInput = __builtins__.__dict__['input'] |
112 DebugClientOrigInput = __builtins__.__dict__['input'] |
108 __builtins__.__dict__['input'] = DebugClientInput |
113 __builtins__.__dict__['input'] = DebugClientRawInput |
109 except (AttributeError, KeyError): |
114 except (AttributeError, KeyError): |
110 try: |
115 import __main__ |
111 import __main__ |
116 DebugClientOrigInput = __main__.__builtins__.__dict__['input'] |
112 DebugClientOrigInput = __main__.__builtins__.__dict__['input'] |
117 __main__.__builtins__.__dict__['input'] = DebugClientRawInput |
113 __main__.__builtins__.__dict__['input'] = DebugClientInput |
|
114 except (AttributeError, KeyError): |
|
115 DebugClientOrigInput = lambda x: '' # __IGNORE_WARNING__ |
|
116 |
118 |
117 ############################################################################### |
119 ############################################################################### |
118 |
120 |
119 |
121 |
120 def DebugClientFork(): |
122 def DebugClientFork(): |