# HG changeset patch # User Matt Hooks # Date 1455313442 18000 # Fri Feb 12 16:44:02 2016 -0500 # Node ID 6484c9e863f36f150fb87dcfbe693c56e650aaec # Parent 37bacf3fa1f572223fecd7230e68ac4f72850016 Issue #26352: Avoid prompting on stderr by default in fallback_getpass diff -r 37bacf3fa1f5 -r 6484c9e863f3 Lib/getpass.py --- a/Lib/getpass.py Thu Feb 11 10:26:27 2016 -0500 +++ b/Lib/getpass.py Fri Feb 12 16:44:02 2016 -0500 @@ -122,8 +122,8 @@ warnings.warn("Can not control echo on the terminal.", GetPassWarning, stacklevel=2) if not stream: - stream = sys.stderr - print("Warning: Password input may be echoed.", file=stream) + stream = sys.stdout + print("Warning: Password input may be echoed.", file=sys.stderr) return _raw_input(prompt, stream) diff -r 37bacf3fa1f5 -r 6484c9e863f3 Lib/test/test_getpass.py --- a/Lib/test/test_getpass.py Thu Feb 11 10:26:27 2016 -0500 +++ b/Lib/test/test_getpass.py Fri Feb 12 16:44:02 2016 -0500 @@ -47,6 +47,15 @@ self.assertRaises(ImportError, getpass.getuser) +class GetpassFallbackTest(unittest.TestCase): + + def test_prompt_on_stdout_as_default(self): + # see issue 26352 + with mock.patch('sys.stdout') as stdout, mock.patch('sys.stdin', new=StringIO("input_string")): + getpass.fallback_getpass(prompt="some_prompt") + stdout.write.assert_called_once_with("some_prompt") + + class GetpassRawinputTest(unittest.TestCase): def test_flushes_stream_after_prompt(self):