Skip to content

Fix UnicodeEncodeError on Windows. #3043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,9 @@ def hosting_method(self) -> HostingMethod:

def startup(self):
logger.line()
if os.name != "nt":
logger.info("┌┬┐┌─┐┌┬┐┌┬┐┌─┐┬┬")
logger.info("││││ │ │││││├─┤││")
logger.info("┴ ┴└─┘─┴┘┴ ┴┴ ┴┴┴─┘")
else:
logger.info("MODMAIL")
logger.info("┌┬┐┌─┐┌┬┐┌┬┐┌─┐┬┬")
logger.info("││││ │ │││││├─┤││")
logger.info("┴ ┴└─┘─┴┘┴ ┴┴ ┴┴┴─┘")
logger.info("v%s", __version__)
logger.info("Authors: kyb3r, fourjr, Taaku18")
logger.line()
Expand Down Expand Up @@ -659,7 +656,7 @@ async def convert_emoji(self, name: str) -> str:
try:
name = await converter.convert(ctx, name.strip(":"))
except commands.BadArgument as e:
logger.warning("%s is not a valid emoji. %s.", e)
logger.warning("%s is not a valid emoji. %s.", name, e)
raise
return name

Expand Down
2 changes: 2 additions & 0 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ async def debug(self, ctx):
os.path.dirname(os.path.abspath(__file__)), f"../temp/{log_file_name}.log"
),
"r+",
encoding="utf-8",
) as f:
logs = f.read().strip()

Expand Down Expand Up @@ -448,6 +449,7 @@ async def debug_hastebin(self, ctx):
os.path.dirname(os.path.abspath(__file__)), f"../temp/{log_file_name}.log"
),
"rb+",
encoding="utf-8",
) as f:
logs = BytesIO(f.read().strip())

Expand Down
4 changes: 3 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def format(self, record):

def configure_logging(name, level=None):
global ch_debug, log_level
ch_debug = RotatingFileHandler(name, mode="a+", maxBytes=48000, backupCount=1)
ch_debug = RotatingFileHandler(
name, mode="a+", maxBytes=48000, backupCount=1, encoding="utf-8"
)

formatter_debug = FileFormatter(
"%(asctime)s %(name)s[%(lineno)d] - %(levelname)s: %(message)s",
Expand Down