]> granicus.if.org Git - python/commitdiff
Be nicer to systems that have neither termios nor msvcrt.
authorGuido van Rossum <guido@python.org>
Mon, 13 Apr 1998 20:22:21 +0000 (20:22 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 13 Apr 1998 20:22:21 +0000 (20:22 +0000)
Lib/getpass.py

index 44e78c264be2e145ddea47b155a93a204ad57681..8bd75233f139f4de1db0c4d9d2fb2ccaab5b3d63 100644 (file)
@@ -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.