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 f0aea63..66b1aee 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -20,6 +20,10 @@
import sys
try:
+ fd = sys.stdin.fileno()
+ except:
+ return default_getpass(prompt)
+ try:
import termios, TERMIOS
except ImportError:
try:
@@ -29,10 +33,6 @@
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[:]