MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / win_getpass

Function win_getpass

tools/python-3.11.9-amd64/Lib/getpass.py:97–117  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

95
96
97def win_getpass(prompt='Password: ', stream=None):
98 """Prompt for password with echo off, using Windows getwch()."""
99 if sys.stdin is not sys.__stdin__:
100 return fallback_getpass(prompt, stream)
101
102 for c in prompt:
103 msvcrt.putwch(c)
104 pw = ""
105 while 1:
106 c = msvcrt.getwch()
107 if c == '\r' or c == '\n':
108 break
109 if c == '\003':
110 raise KeyboardInterrupt
111 if c == '\b':
112 pw = pw[:-1]
113 else:
114 pw = pw + c
115 msvcrt.putwch('\r')
116 msvcrt.putwch('\n')
117 return pw
118
119
120def fallback_getpass(prompt='Password: ', stream=None):

Callers

nothing calls this directly

Calls 1

fallback_getpassFunction · 0.85

Tested by

no test coverage detected