1313CYGWIN = sys .platform .startswith ("cygwin" )
1414WIN = sys .platform .startswith ("win" )
1515MAC = sys .platform == "darwin"
16- auto_wrap_for_ansi : t .Callable [[t .TextIO ], t .TextIO ] | None = None
1716_ansi_re = re .compile (r"\033\[[;?0-9]*[a-zA-Z]" )
1817
1918
@@ -511,9 +510,7 @@ def should_strip_ansi(
511510 return not color
512511
513512
514- # On Windows, wrap the output streams with colorama to support ANSI
515- # color codes.
516- # NOTE: double check is needed so mypy does not analyze this on Linux
513+ # double check is needed so mypy does not analyze this on Linux
517514if sys .platform .startswith ("win" ) and WIN :
518515 from ._winconsole import _get_windows_console_stream
519516
@@ -522,43 +519,6 @@ def _get_argv_encoding() -> str:
522519
523520 return locale .getpreferredencoding ()
524521
525- _ansi_stream_wrappers : cabc .MutableMapping [t .TextIO , t .TextIO ] = WeakKeyDictionary ()
526-
527- def auto_wrap_for_ansi (stream : t .TextIO , color : bool | None = None ) -> t .TextIO :
528- """Support ANSI color and style codes on Windows by wrapping a
529- stream with colorama.
530- """
531- try :
532- cached = _ansi_stream_wrappers .get (stream )
533- except Exception :
534- cached = None
535-
536- if cached is not None :
537- return cached
538-
539- import colorama
540-
541- strip = should_strip_ansi (stream , color )
542- ansi_wrapper = colorama .AnsiToWin32 (stream , strip = strip )
543- rv = t .cast (t .TextIO , ansi_wrapper .stream )
544- _write = rv .write
545-
546- def _safe_write (s : str ) -> int :
547- try :
548- return _write (s )
549- except BaseException :
550- ansi_wrapper .reset_all ()
551- raise
552-
553- rv .write = _safe_write # type: ignore[method-assign]
554-
555- try :
556- _ansi_stream_wrappers [stream ] = rv
557- except Exception :
558- pass
559-
560- return rv
561-
562522else :
563523
564524 def _get_argv_encoding () -> str :
0 commit comments