summaryrefslogtreecommitdiffstats
path: root/Lib/getpass.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-09-22 02:38:42 (GMT)
committerGuido van Rossum <guido@python.org>1998-09-22 02:38:42 (GMT)
commit0238a25b20357f34f8b678373264c5ead2aecc5a (patch)
tree49b243d393e2fefca33e141cb78ff5e0427c3511 /Lib/getpass.py
parentef0056ae1a5f6dd2cc10505fb10e7653418d7f1f (diff)
downloadcpython-0238a25b20357f34f8b678373264c5ead2aecc5a.zip
cpython-0238a25b20357f34f8b678373264c5ead2aecc5a.tar.gz
cpython-0238a25b20357f34f8b678373264c5ead2aecc5a.tar.bz2
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.
Diffstat (limited to 'Lib/getpass.py')
-rw-r--r--Lib/getpass.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py
index f0aea63..66b1aee 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -20,6 +20,10 @@ def getpass(prompt='Password: '):
import sys
try:
+ fd = sys.stdin.fileno()
+ except:
+ return default_getpass(prompt)
+ try:
import termios, TERMIOS
except ImportError:
try:
@@ -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[:]