[New-bugs-announce] [issue26352] getpass incorrectly displays password prompt on stderr on fallback

Matt Hooks report at bugs.python.org
Fri Feb 12 16:10:50 EST 2016

New submission from Matt Hooks:

When calling getpass.getpass(), certain circumstances cause it to fallback to getpass.fallback_getpass, such as when swapping out sys.stdin for another object in a unit test.

In such a circumstance, fallback_getpass may be called with stream=None when getpass itself was called without a stream.  fallback_getpass needs a stream to write the "Warning: Password input may be echoed" warning to, and reasonably chooses stderr.  However, this choice persists down into getpass._raw_input, where the user is then shown the password prompt on stderr as well.  Instead of on stderr, the user should get the password prompt on stdout.

tl;dr: Some calls to getpass.getpass result in a password prompt on stderr.

Bad behavior: password prompt displayed over stderr.
Expected behavior: password prompt should be on stdout.

Found in 3.4, looks like it's the same in 3.5.

I will attach a patch in a few moments, after I get my dev environment sorted out.

components: Library (Lib)
messages: 260202
nosy: Matt Hooks
priority: normal
severity: normal
status: open
title: getpass incorrectly displays password prompt on stderr on fallback
type: behavior
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list