Skip to content

Commit 074f3b2

Browse files
authored
gh-138577: Mention Unix-specific limitations of getpass.getpass(echo_char=...) (#138677)
In bf8bbe9, `getpass.getpass` gained the ability to provide keyboard feedback through `echo_char`. On Unix, line editing shortcuts such as Ctrl+U were previously handled as the terminal operates in canonical mode (see termios(3)). However, since keyboard feedback requires to switch to noncanonical mode, this now results in an inconsistency when `getpass.getpass` uses `echo_char` as those shortcuts are no more supported. This limitation is specific to Unix and does not affect Windows users where line editing shortcuts were never supported.
1 parent fd2e3d1 commit 074f3b2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Doc/library/getpass.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ The :mod:`getpass` module provides two functions:
3939
If you call getpass from within IDLE, the input may be done in the
4040
terminal you launched IDLE from rather than the idle window itself.
4141

42+
.. note::
43+
On Unix systems, when *echo_char* is set, the terminal will be
44+
configured to operate in
45+
:manpage:`noncanonical mode <termios(3)#Canonical_and_noncanonical_mode>`.
46+
In particular, this means that line editing shortcuts such as
47+
:kbd:`Ctrl+U` will not work and may insert unexpected characters into
48+
the input.
49+
4250
.. versionchanged:: 3.14
4351
Added the *echo_char* parameter for keyboard feedback.
4452

0 commit comments

Comments
 (0)