If sys.stdin is not a tty, fall back to default_getpass after printing

a warning instead of failing with a termios.error.
This commit is contained in:
Gregory P. Smith 2008-04-21 21:31:08 +00:00
parent aa3cadb01e
commit 41e3018336
2 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,10 @@ def unix_getpass(prompt='Password: ', stream=None):
if stream is None:
stream = sys.stdout
if not sys.stdin.isatty():
print >>sys.stderr, "Warning: sys.stdin is not a tty."
return default_getpass(prompt)
try:
fd = sys.stdin.fileno()
except:

View File

@ -37,6 +37,9 @@ Extensions Modules
Library
-------
- getpass.getpass() now works when sys.stdin is not a tty by printing a warning
and falling back to sys.stdin.readline instead of raising termios.error.
- Issue #2014: Allow XML-RPC datetime objects to have dates before
1900-01-01.