diff options
Diffstat (limited to 'Lib/getpass.py')
-rw-r--r-- | Lib/getpass.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py index 53c38b88975..27403634883 100644 --- a/Lib/getpass.py +++ b/Lib/getpass.py @@ -135,7 +135,12 @@ def _raw_input(prompt="", stream=None, input=None): input = sys.stdin prompt = str(prompt) if prompt: - stream.write(prompt) + try: + stream.write(prompt) + except UnicodeEncodeError: + prompt = prompt.encode(stream.encoding, 'replace') + prompt = prompt.decode(stream.encoding) + stream.write(prompt) stream.flush() # NOTE: The Python C API calls flockfile() (and unlock) during readline. line = input.readline() |