MCPcopy Index your code
hub / github.com/RustPython/RustPython / win_getpass

Function win_getpass

Lib/getpass.py:105–132  ·  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

103
104
105def win_getpass(prompt='Password: ', stream=None, *, echo_char=None):
106 """Prompt for password with echo off, using Windows getwch()."""
107 if sys.stdin is not sys.__stdin__:
108 return fallback_getpass(prompt, stream)
109 _check_echo_char(echo_char)
110
111 for c in prompt:
112 msvcrt.putwch(c)
113 pw = ""
114 while 1:
115 c = msvcrt.getwch()
116 if c == '\r' or c == '\n':
117 break
118 if c == '\003':
119 raise KeyboardInterrupt
120 if c == '\b':
121 if echo_char and pw:
122 msvcrt.putwch('\b')
123 msvcrt.putwch(' ')
124 msvcrt.putwch('\b')
125 pw = pw[:-1]
126 else:
127 pw = pw + c
128 if echo_char:
129 msvcrt.putwch(echo_char)
130 msvcrt.putwch('\r')
131 msvcrt.putwch('\n')
132 return pw
133
134
135def 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