mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Be nicer to systems that have neither termios nor msvcrt.
This commit is contained in:
parent
a16e2753ed
commit
fb9b7fd5ee
1 changed files with 10 additions and 1 deletions
|
@ -22,7 +22,12 @@ def getpass(prompt='Password: '):
|
|||
try:
|
||||
import termios, TERMIOS
|
||||
except ImportError:
|
||||
return win_getpass(prompt)
|
||||
try:
|
||||
import msvcrt
|
||||
except ImportError:
|
||||
return default_getpass(prompt)
|
||||
else:
|
||||
return win_getpass(prompt)
|
||||
|
||||
fd = sys.stdin.fileno()
|
||||
old = termios.tcgetattr(fd) # a copy to save
|
||||
|
@ -59,6 +64,10 @@ def win_getpass(prompt='Password: '):
|
|||
return pw
|
||||
|
||||
|
||||
def default_getpass(prompt='Password: '):
|
||||
return raw_input(prompt)
|
||||
|
||||
|
||||
def getuser():
|
||||
"""Get the username from the environment or password database.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue