mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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.
This commit is contained in:
parent
ef0056ae1a
commit
0238a25b20
1 changed files with 4 additions and 4 deletions
|
@ -19,6 +19,10 @@ def getpass(prompt='Password: '):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
try:
|
||||||
|
fd = sys.stdin.fileno()
|
||||||
|
except:
|
||||||
|
return default_getpass(prompt)
|
||||||
try:
|
try:
|
||||||
import termios, TERMIOS
|
import termios, TERMIOS
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -29,10 +33,6 @@ def getpass(prompt='Password: '):
|
||||||
else:
|
else:
|
||||||
return win_getpass(prompt)
|
return win_getpass(prompt)
|
||||||
|
|
||||||
try:
|
|
||||||
fd = sys.stdin.fileno()
|
|
||||||
except:
|
|
||||||
return default_getpass(prompt)
|
|
||||||
old = termios.tcgetattr(fd) # a copy to save
|
old = termios.tcgetattr(fd) # a copy to save
|
||||||
new = old[:]
|
new = old[:]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue