diff --git a/Lib/getpass.py b/Lib/getpass.py index f0aea63ac34..66b1aeebcf5 100644 --- a/Lib/getpass.py +++ b/Lib/getpass.py @@ -19,6 +19,10 @@ def getpass(prompt='Password: '): """ import sys + try: + fd = sys.stdin.fileno() + except: + return default_getpass(prompt) try: import termios, TERMIOS except ImportError: @@ -29,10 +33,6 @@ def getpass(prompt='Password: '): else: return win_getpass(prompt) - try: - fd = sys.stdin.fileno() - except: - return default_getpass(prompt) old = termios.tcgetattr(fd) # a copy to save new = old[:]