Skip to content

Commit 3f1a861

Browse files
fix: disable IEXTEN in non-canonical mode to allow Ctrl+V (LNEXT) handling
1 parent d280ce9 commit 3f1a861

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Lib/getpass.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def unix_getpass(prompt='Password: ', stream=None, *, echo_char=None):
111111
term_ctrl_chars = None
112112
if echo_char:
113113
new[3] &= ~termios.ICANON
114+
new[3] &= ~termios.IEXTEN
114115
term_ctrl_chars = _get_terminal_ctrl_chars(fd)
115116
tcsetattr_flags = termios.TCSAFLUSH
116117
if hasattr(termios, 'TCSASOFT'):

Lib/test/test_getpass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ def test_kill_ctrl_u_with_echo_char(self):
216216
result = getpass._raw_input('Password: ', mock_output, mock_input,
217217
'*')
218218
self.assertEqual(result, expect_result)
219-
# Should show "***" then clear all 3, then show "***" for "bar"
219+
# Should show "***" then refresh to clear, then show "***" for "bar"
220220
output = mock_output.getvalue()
221221
self.assertIn('***', output)
222-
# Should have backspaces to clear the "foo" part
223-
self.assertIn('\b', output)
222+
# Display refresh uses \r to rewrite the line including prompt
223+
self.assertIn('\r', output)
224224

225225
def test_werase_ctrl_w_with_echo_char(self):
226226
# Ctrl+W (WERASE) should delete the previous word

0 commit comments

Comments
 (0)