From: yagggi Date: Tue, 9 Sep 2025 09:41:13 +0000 (+0800) Subject: gh-138577: Mention Unix-specific limitations of `getpass.getpass(echo_char=...)`... X-Git-Tag: v3.15.0a1~434 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=074f3b20b3f05e2740f5324f1b0653152a41ca82;p=thirdparty%2FPython%2Fcpython.git gh-138577: Mention Unix-specific limitations of `getpass.getpass(echo_char=...)` (#138677) In bf8bbe9a813dd9fc2dd14be06df172b7d26ca1af, `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. --- diff --git a/Doc/library/getpass.rst b/Doc/library/getpass.rst index 0fb0fc88683c..af9c9e9f39d9 100644 --- a/Doc/library/getpass.rst +++ b/Doc/library/getpass.rst @@ -39,6 +39,14 @@ The :mod:`getpass` module provides two functions: If you call getpass from within IDLE, the input may be done in the terminal you launched IDLE from rather than the idle window itself. + .. note:: + On Unix systems, when *echo_char* is set, the terminal will be + configured to operate in + :manpage:`noncanonical mode `. + In particular, this means that line editing shortcuts such as + :kbd:`Ctrl+U` will not work and may insert unexpected characters into + the input. + .. versionchanged:: 3.14 Added the *echo_char* parameter for keyboard feedback.