]> granicus.if.org Git - python/commitdiff
Do the check for lacking sys.stdin.fileno() *before* testing for
authorGuido van Rossum <guido@python.org>
Tue, 22 Sep 1998 02:38:42 +0000 (02:38 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 22 Sep 1998 02:38:42 +0000 (02:38 +0000)
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.

Lib/getpass.py

index f0aea63ac34930ef49d19acbaea0a0a9d2daf4fe..66b1aeebcf546f82721c836226c20264f87f5c08 100644 (file)
@@ -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[:]