Skip to content
Myr

Password prompt now prints a newline on `^C`.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parent ccba374 · Browse files · 3 files+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+21 added−0 removed

  • tests:+15 added−0 removed
  • other:+6 added−0 removed

3 files+21 added−0 removed

modified:click/termui.py+5 added
67 unmodified lines
68 # coloring through colorama on Windows69 echo(text, nl=False, err=err)70 return f('')71 except (KeyboardInterrupt, EOFError):72 # getpass doesn't print a newline if the user aborts input with ^C.73 # Allegedly this behavior is inherited from getpass(3).74 # A doc bug has been filed at https://bugs.python.org/issue2471175 if hide_input:76 echo(None, err=err)77 raise Abort()7879 if value_proc is None:80 value_proc = convert_type(type, default)
456 unmodified lines
modified:tests/test_utils.py+15 added
122 unmodified lines
123 assert not result.exception124 assert result.output == 'Foo [Y/n]: n\nno :(\n'125126127def test_prompts_abort(monkeypatch, capsys):128 def f(_):129 raise KeyboardInterrupt()130131 monkeypatch.setattr('click.termui.hidden_prompt_func', f)132133 try:134 click.prompt('Password', hide_input=True)135 except click.Abort:136 click.echo('Screw you.')137138 out, err = capsys.readouterr()139 assert out == 'Password: \nScrew you.\n'140141142def test_echo_via_pager(monkeypatch, capfd):143 monkeypatch.setitem(os.environ, 'PAGER', 'cat')144 monkeypatch.setattr(click._termui_impl, 'isatty', lambda x: True)145 click.echo_via_pager('haha')
127 unmodified lines
modified:CHANGES+1 added
18 unmodified lines
19 linked list of contexts to allow click utilities to place state there.20- introduced `Context.scope`.21- The `echo` function is now threadsafe: It calls the `write` method of the22 underlying object only once.23- `prompt(hide_input=True)` now prints a newline on `^C`.2425Version 4.126-----------27
221 unmodified lines