Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 604453c

Browse files
committed
#21169: add comment and doc update for getpass change.
1 parent 04d8a24 commit 604453c

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

Doc/library/getpass.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ The :mod:`getpass` module provides two functions:
1313
.. function:: getpass(prompt='Password: ', stream=None)
1414

1515
Prompt the user for a password without echoing. The user is prompted using
16-
the string *prompt*, which defaults to ``'Password: '``. On Unix, the prompt
17-
is written to the file-like object *stream*. *stream* defaults to the
18-
controlling terminal (:file:`/dev/tty`) or if that is unavailable to
19-
``sys.stderr`` (this argument is ignored on Windows).
16+
the string *prompt*, which defaults to ``'Password: '``. On Unix, the
17+
prompt is written to the file-like object *stream* using the replace error
18+
handler if needed. *stream* defaults to the controlling terminal
19+
(:file:`/dev/tty`) or if that is unavailable to ``sys.stderr`` (this
20+
argument is ignored on Windows).
2021

2122
If echo free input is unavailable getpass() falls back to printing
2223
a warning message to *stream* and reading from ``sys.stdin`` and

Lib/getpass.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def _raw_input(prompt="", stream=None, input=None):
138138
try:
139139
stream.write(prompt)
140140
except UnicodeEncodeError:
141+
# Use replace error handler to get as much as possible printed.
141142
prompt = prompt.encode(stream.encoding, 'replace')
142143
prompt = prompt.decode(stream.encoding)
143144
stream.write(prompt)

0 commit comments

Comments
 (0)