Title: getpass.getpass not working with on windows when ctrl+v is used to enter the string
Type: behavior Stage:
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Atul Bagga, brianhrutledge, docs@python, eryksun, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-06-27 09:49 by Atul Bagga, last changed 2020-08-23 19:01 by terry.reedy.

Messages (5)
msg346721 - (view) Author: Atul Bagga (Atul Bagga) Date: 2019-06-27 09:49
Detailed issue filed here -
msg346727 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2019-06-27 11:00
getpass() reads from the console via msvcrt.getwch(). This is a raw console read, so Ctrl+V is read as the SYN (0x16) control character. Only the following keys are handled specially by getpass: 

* Ctrl+C - raise KeyboardInterrupt
* Ctrl+H (backspace) - delete the previous character
* Ctrl+J (linefeed) and Ctrl+M (return) - return

getpass() behaves pretty much the same in a Linux terminal emulator, except Ctrl+H isn't backspace. 

Recent versions of the console host in Windows 10 have an option to support pasting via Ctrl+Shift+V, regardless of the input mode. This is pretty common in Unix terminal emulators as well. You can change this setting in the Properties->Options dialog for a particular window or shortcut, or the default setting in the Defaults->Options dialog. In the "HKCU\Console" registry key, the DWORD value name is "InterceptCopyPaste".
msg346867 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-06-28 21:19
If anything, this seems to be a getpass doc issue.
msg347126 - (view) Author: Atul Bagga (Atul Bagga) Date: 2019-07-02 10:04
Suprisingly this works fine on ConEMU which I commonly use on windows though internally I still use powershell on conemu.

It does not work on CMD and Powershell consoles.
msg375819 - (view) Author: Brian Rutledge (brianhrutledge) Date: 2020-08-23 17:46
In addition to Ctrl+V, Shift+Insert also doesn't work. This behavior is the same Command Prompt and PowerShell on Windows 10.

Workarounds include:

- Clicking `Edit > Paste` from the window menu
- Enabling `Properties > Options > Use Ctrl+Shift+C/V as Copy/Paste` from the menu
- Use right-click to paste
- Using the new Windows Terminal:

I stumbled upon this issue while investigating Thanks for writing it up!
Date User Action Args
2020-08-23 19:01:16terry.reedysetversions: - Python 3.6, Python 3.7
2020-08-23 17:46:22brianhrutledgesetnosy: + brianhrutledge

messages: + msg375819
versions: + Python 3.7, Python 3.8, Python 3.9, Python 3.10
2019-07-02 10:04:03Atul Baggasetmessages: + msg347126
2019-06-28 21:19:47terry.reedysetnosy: + terry.reedy, docs@python
messages: + msg346867

assignee: docs@python
components: + Documentation, - Library (Lib), Windows
2019-06-27 11:00:55eryksunsetnosy: + eryksun
messages: + msg346727
2019-06-27 10:32:50xtreaksetnosy: + tim.golden, steve.dower, zach.ware, paul.moore
components: + Windows
2019-06-27 09:49:37Atul Baggacreate