mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Ensure nothing initializes colorama when it isn't needed (#5063)
This commit is contained in:
parent
a6c438e486
commit
b89c43eb0f
@ -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__)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ import discord
|
||||
# Set the event loop policies here so any subsequent `new_event_loop()`
|
||||
# calls, in particular those as a result of the following imports,
|
||||
# return the correct loop object.
|
||||
from redbot import _update_event_loop_policy, __version__
|
||||
from redbot import _early_init, __version__
|
||||
|
||||
_update_event_loop_policy()
|
||||
_early_init()
|
||||
|
||||
import redbot.logging
|
||||
from redbot.core.bot import Red, ExitCodes
|
||||
|
||||
@ -9,6 +9,10 @@ from copy import deepcopy
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any, Optional, Union
|
||||
|
||||
from redbot import _early_init
|
||||
|
||||
_early_init()
|
||||
|
||||
import appdirs
|
||||
import click
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user