summaryrefslogtreecommitdiffstats
path: root/Lib/getpass.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-04-21 21:31:08 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-04-21 21:31:08 (GMT)
commit41e30183367e52450fdf7316cf32bfa4e9a78afc (patch)
treef643e5118416fb35af9d9d17b022d43d5f110652 /Lib/getpass.py
parentaa3cadb01e47719b9f8b7401cdbd32791b5e16f7 (diff)
downloadcpython-41e30183367e52450fdf7316cf32bfa4e9a78afc.zip
cpython-41e30183367e52450fdf7316cf32bfa4e9a78afc.tar.gz
cpython-41e30183367e52450fdf7316cf32bfa4e9a78afc.tar.bz2
If sys.stdin is not a tty, fall back to default_getpass after printing
a warning instead of failing with a termios.error.
Diffstat (limited to 'Lib/getpass.py')
-rw-r--r--Lib/getpass.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py
index 6b78612..07c89ff 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -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: