From: Guido van Rossum Date: Tue, 22 Sep 1998 02:38:42 +0000 (+0000) Subject: Do the check for lacking sys.stdin.fileno() *before* testing for X-Git-Tag: v1.5.2a2~258 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0238a25b20357f34f8b678373264c5ead2aecc5a;p=python Do the check for lacking sys.stdin.fileno() *before* testing for Windows. If sys.stdin doesn't appear to be a real file (characterized by having a working fileno()), don't use any console specific methods -- go straight to the default. --- diff --git a/Lib/getpass.py b/Lib/getpass.py index f0aea63ac3..66b1aeebcf 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[:]