summaryrefslogtreecommitdiffstats
path: root/Lib/getpass.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-04-14 02:09:29 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-04-14 02:09:29 (GMT)
commite084e97f9f502908534bc87596c5bb7b6ff9a684 (patch)
tree687757481ac5041a7a7b8656cda4a8f51ba86b32 /Lib/getpass.py
parentfc8e9883bef8058723a38f6c8db6549ad611a633 (diff)
parentd5aa487cceac54fdf2b5c073157b899b3c8c9c94 (diff)
downloadcpython-e084e97f9f502908534bc87596c5bb7b6ff9a684.zip
cpython-e084e97f9f502908534bc87596c5bb7b6ff9a684.tar.gz
cpython-e084e97f9f502908534bc87596c5bb7b6ff9a684.tar.bz2
Mierge #21169: fix getpass to use replace error handler on UnicodeEncodeError.
Diffstat (limited to 'Lib/getpass.py')
-rw-r--r--Lib/getpass.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py
index 53c38b8..2740363 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()