MCPcopy Index your code
hub / github.com/python/cpython / win_getpass

Function win_getpass

Lib/getpass.py:156–183  ·  view source on GitHub ↗

Prompt for password with echo off, using Windows getwch().

(prompt='Password: ', stream=None, *, echo_char=None)

Source from the content-addressed store, hash-verified

154
155
156def win_getpass(prompt='Password: ', stream=None, *, echo_char=None):
157 """Prompt for password with echo off, using Windows getwch()."""
158 if sys.stdin is not sys.__stdin__:
159 return fallback_getpass(prompt, stream)
160 _check_echo_char(echo_char)
161
162 for c in prompt:
163 msvcrt.putwch(c)
164 pw = ""
165 while 1:
166 c = msvcrt.getwch()
167 if c == '\r' or c == '\n':
168 break
169 if c == '\003':
170 raise KeyboardInterrupt
171 if c == '\b':
172 if echo_char and pw:
173 msvcrt.putwch('\b')
174 msvcrt.putwch(' ')
175 msvcrt.putwch('\b')
176 pw = pw[:-1]
177 else:
178 pw = pw + c
179 if echo_char:
180 msvcrt.putwch(echo_char)
181 msvcrt.putwch('\r')
182 msvcrt.putwch('\n')
183 return pw
184
185
186def fallback_getpass(prompt='Password: ', stream=None, *, echo_char=None):

Callers

nothing calls this directly

Calls 2

fallback_getpassFunction · 0.85
_check_echo_charFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…