summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-04-13 20:22:21 (GMT)
committerGuido van Rossum <guido@python.org>1998-04-13 20:22:21 (GMT)
commitfb9b7fd5ee265255c18f8c1f6220f7ea27f5ed97 (patch)
tree3c0e07ff192b6f285ab5488703537e573220964b
parenta16e2753edfee437fda7248ad0195f509c901d33 (diff)
downloadcpython-fb9b7fd5ee265255c18f8c1f6220f7ea27f5ed97.zip
cpython-fb9b7fd5ee265255c18f8c1f6220f7ea27f5ed97.tar.gz
cpython-fb9b7fd5ee265255c18f8c1f6220f7ea27f5ed97.tar.bz2
Be nicer to systems that have neither termios nor msvcrt.
-rw-r--r--Lib/getpass.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py
index 44e78c2..8bd7523 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -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.