Skip to content
Myr

Try hard to not screw up cmd.exe on windows on interrupts.

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

authored by Armin Ronacher · committed by Armin Ronacher · parent 0135331 · Browse files · 2 files+19 added−1 removed
This commit

State

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

Diff stats

2 files+19 added−1 removed

  • other:+19 added−1 removed

2 files+19 added−1 removed

modified:click/_compat.py+17 added-1 removed
459 unmodified lines
460 else:461 _ansi_stream_wrappers = WeakKeyDictionary()462463 def auto_wrap_for_ansi(stream):464 """This function wraps a stream so that calls through colorama465 are issued to the win32 console API to recolor on demand. It466 also ensures to reset the colors if a write call is interrupted467 to not destroy the console afterwards.468 """469 try:470 cached = _ansi_stream_wrappers.get(stream)471 except Exception:472 cached = None473 if cached is not None:474 return cached475 strip = not isatty(stream)471 rv = colorama.AnsiToWin32(stream, strip=strip).stream476 ansi_wrapper = colorama.AnsiToWin32(stream, strip=strip)477 rv = ansi_wrapper.stream478 _write = rv.write479480 def _safe_write(s):481 try:482 return _write(s)483 except:484 ansi_wrapper.reset_all()485 raise486487 rv.write = _safe_write488 try:489 _ansi_stream_wrappers[stream] = rv490 except Exception:491 pass
51 unmodified lines
modified:CHANGES+2 added
7 unmodified lines
89(bugfix release, release date to be decided)1011- fixed the :func:`launch` function on windows.12- improved the colorama support on windows to try hard to not13 screw up the console if the application is interrupted.1415Version 2.016-----------17
53 unmodified lines