Skip to content

Commit fb9b7fd

Browse files
committed
Be nicer to systems that have neither termios nor msvcrt.
1 parent a16e275 commit fb9b7fd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Lib/getpass.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ def getpass(prompt='Password: '):
2222
try:
2323
import termios, TERMIOS
2424
except ImportError:
25-
return win_getpass(prompt)
25+
try:
26+
import msvcrt
27+
except ImportError:
28+
return default_getpass(prompt)
29+
else:
30+
return win_getpass(prompt)
2631

2732
fd = sys.stdin.fileno()
2833
old = termios.tcgetattr(fd) # a copy to save
@@ -59,6 +64,10 @@ def win_getpass(prompt='Password: '):
5964
return pw
6065

6166

67+
def default_getpass(prompt='Password: '):
68+
return raw_input(prompt)
69+
70+
6271
def getuser():
6372
"""Get the username from the environment or password database.
6473

0 commit comments

Comments
 (0)