[New-bugs-announce] [issue1703] getpass broken in Py3k: must flush()
report at bugs.python.org
Fri Dec 28 01:14:34 CET 2007
New submission from Philip Jenvey:
getpass (in particular _raw_input, used by unix_getpass and
default_getpass) prints out a password prompt to a stream (by default
stdout) but doesn't flush that stream. It assumes calling
sys.stdin.readline() to read the password causes stdout to be flushed
(probably a libc file buffering behavior)
This is a problem in Py3k where file buffering is done by Python;
getpass needs to manually flush the stream it prints the prompt to.
Otherwise the prompt isn't printed until after the password is entered
Python 3.0a2 (py3k:59601, Dec 27 2007, 14:28:14)
[GCC 4.1.3 20071209 (prerelease) (Debian 4.1.2-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import getpass
<no prompt is printed, i type 'foo\n', and only afterwards is the prompt
Windows doesn't use _raw_input so it wouldn't see this issue.
Attached is a patch to flush the stream. There's no getpass tests so I
didn't get around to creating one for this issue. Ideally we'd test
getpass via spawning a python subprocess and ensuring its I/O looked
This was noticed on Jython as its file object is now based off Py3k's
components: Library (Lib)
title: getpass broken in Py3k: must flush()
versions: Python 3.0
Added file: http://bugs.python.org/file9031/getpass_flush-r59601.diff
Tracker <report at bugs.python.org>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the New-bugs-announce