mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
Ensure nothing initializes colorama when it isn't needed (#5063)
This commit is contained in:
@@ -191,6 +191,29 @@ def _update_event_loop_policy():
|
||||
_asyncio.set_event_loop_policy(_uvloop.EventLoopPolicy())
|
||||
|
||||
|
||||
def _ensure_no_colorama():
|
||||
# a hacky way to ensure that nothing initialises colorama
|
||||
# if we're not running with legacy Windows command line mode
|
||||
from rich.console import detect_legacy_windows
|
||||
|
||||
if not detect_legacy_windows():
|
||||
import colorama
|
||||
import colorama.initialise
|
||||
|
||||
colorama.deinit()
|
||||
|
||||
def _colorama_wrap_stream(stream, *args, **kwargs):
|
||||
return stream
|
||||
|
||||
colorama.wrap_stream = _colorama_wrap_stream
|
||||
colorama.initialise.wrap_stream = _colorama_wrap_stream
|
||||
|
||||
|
||||
def _early_init():
|
||||
_update_event_loop_policy()
|
||||
_ensure_no_colorama()
|
||||
|
||||
|
||||
__version__ = "3.4.10.dev1"
|
||||
version_info = VersionInfo.from_str(__version__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user