Kaydet (Commit) 41e30183 authored tarafından Gregory P. Smith's avatar Gregory P. Smith

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

a warning instead of failing with a termios.error.
üst aa3cadb0
...@@ -24,6 +24,10 @@ def unix_getpass(prompt='Password: ', stream=None): ...@@ -24,6 +24,10 @@ def unix_getpass(prompt='Password: ', stream=None):
if stream is None: if stream is None:
stream = sys.stdout stream = sys.stdout
if not sys.stdin.isatty():
print >>sys.stderr, "Warning: sys.stdin is not a tty."
return default_getpass(prompt)
try: try:
fd = sys.stdin.fileno() fd = sys.stdin.fileno()
except: except:
......
...@@ -37,6 +37,9 @@ Extensions Modules ...@@ -37,6 +37,9 @@ Extensions Modules
Library 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 - Issue #2014: Allow XML-RPC datetime objects to have dates before
1900-01-01. 1900-01-01.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment