[Python-checkins] r62446 - in python/trunk: Lib/getpass.py Misc/NEWS
gregory.p.smith
python-checkins at python.org
Mon Apr 21 23:31:08 CEST 2008
Author: gregory.p.smith
Date: Mon Apr 21 23:31:08 2008
New Revision: 62446
Log:
If sys.stdin is not a tty, fall back to default_getpass after printing
a warning instead of failing with a termios.error.
Modified:
python/trunk/Lib/getpass.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/getpass.py
==============================================================================
--- python/trunk/Lib/getpass.py (original)
+++ python/trunk/Lib/getpass.py Mon Apr 21 23:31:08 2008
@@ -24,6 +24,10 @@
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:
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Mon Apr 21 23:31:08 2008
@@ -37,6 +37,9 @@
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.
More information about the Python-checkins
mailing list