| 127 | |
| 128 | |
| 129 | def _raw_input(prompt="", stream=None, input=None): |
| 130 | # This doesn't save the string in the GNU readline history. |
| 131 | if not stream: |
| 132 | stream = sys.stderr |
| 133 | if not input: |
| 134 | input = sys.stdin |
| 135 | prompt = str(prompt) |
| 136 | if prompt: |
| 137 | try: |
| 138 | stream.write(prompt) |
| 139 | except UnicodeEncodeError: |
| 140 | # Use replace error handler to get as much as possible printed. |
| 141 | prompt = prompt.encode(stream.encoding, 'replace') |
| 142 | prompt = prompt.decode(stream.encoding) |
| 143 | stream.write(prompt) |
| 144 | stream.flush() |
| 145 | # NOTE: The Python C API calls flockfile() (and unlock) during readline. |
| 146 | line = input.readline() |
| 147 | if not line: |
| 148 | raise EOFError |
| 149 | if line[-1] == '\n': |
| 150 | line = line[:-1] |
| 151 | return line |
| 152 | |
| 153 | |
| 154 | def getuser(): |