diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index 166152c37..0af8ec95d 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -43,7 +43,7 @@ class Downloader: self.LIB_PATH.mkdir(parents=True, exist_ok=True) self.SHAREDLIB_PATH.mkdir(parents=True, exist_ok=True) if not self.SHAREDLIB_INIT.exists(): - with self.SHAREDLIB_INIT.open(mode='w') as _: + with self.SHAREDLIB_INIT.open(mode='w', encoding='utf-8') as _: pass if str(self.LIB_PATH) not in syspath: diff --git a/redbot/cogs/mod/mod.py b/redbot/cogs/mod/mod.py index c4969e43d..f86a5b374 100644 --- a/redbot/cogs/mod/mod.py +++ b/redbot/cogs/mod/mod.py @@ -322,7 +322,7 @@ class Mod: except discord.errors.Forbidden: await ctx.send(_("I'm not allowed to do that.")) except Exception as e: - print(e) + print(str(e, encoding='utf-8', errors='replace')) else: await ctx.send(_("Done. That felt good.")) @@ -379,7 +379,7 @@ class Mod: await ctx.send(_("I'm not allowed to do that.")) except Exception as e: self.ban_queue.remove(queue_entry) - print(e) + print(str(e, encoding='utf-8', errors='replace')) else: await ctx.send(_("Done. It was about time.")) @@ -540,14 +540,14 @@ class Mod: return except discord.HTTPException as e: self.ban_queue.remove(queue_entry) - print(e) + print(str(e, encoding='utf-8', errors='replace')) return self.unban_queue.append(queue_entry) try: await guild.unban(user) except discord.HTTPException as e: self.unban_queue.remove(queue_entry) - print(e) + print(str(e, encoding='utf-8', errors='replace')) return else: await ctx.send(_("Done. Enough chaos.")) @@ -1209,7 +1209,7 @@ class Mod: "Mention spam (Autoban)", until=None, channel=None ) except RuntimeError as e: - print(e) + print(str(e, encoding='utf-8', errors='replace')) return False return True return False @@ -1269,7 +1269,7 @@ class Mod: "ban", member, mod, reason if reason else None) except RuntimeError as e: - print(e) + print(str(e, encoding='utf-8', errors='replace')) async def on_member_unban(self, guild: discord.Guild, user: discord.User): if (guild.id, user.id) in self.unban_queue: @@ -1287,7 +1287,7 @@ class Mod: await modlog.create_case(guild, date, "unban", user, mod, reason) except RuntimeError as e: - print(e) + print(str(e, encoding='utf-8', errors='replace')) async def get_audit_entry_info(self, guild: discord.Guild, diff --git a/redbot/cogs/trivia/trivia.py b/redbot/cogs/trivia/trivia.py index 12d912450..d12b101e7 100644 --- a/redbot/cogs/trivia/trivia.py +++ b/redbot/cogs/trivia/trivia.py @@ -465,7 +465,7 @@ class Trivia: raise FileNotFoundError("Could not find the `{}` category" "".format(category)) - with path.open() as file: + with path.open(encoding='utf-8') as file: try: dict_ = yaml.load(file) except yaml.error.YAMLError as exc: diff --git a/redbot/core/events.py b/redbot/core/events.py index 45131075b..6a78bbc72 100644 --- a/redbot/core/events.py +++ b/redbot/core/events.py @@ -140,7 +140,10 @@ def init_events(bot, cli_flags): print(Fore.RED + INTRO) print(Style.RESET_ALL) - print(bordered(INFO, INFO2, ascii_border=ascii_border)) + print( + str(bordered(INFO, INFO2, ascii_border=ascii_border), + encoding='utf-8', errors='replace') + ) if invite_url: print("\nInvite URL: {}\n".format(invite_url)) diff --git a/redbot/core/i18n.py b/redbot/core/i18n.py index e4a2dce8f..62f4ab50f 100644 --- a/redbot/core/i18n.py +++ b/redbot/core/i18n.py @@ -180,9 +180,9 @@ class CogI18n: try: try: - translation_file = locale_path.open('ru') + translation_file = locale_path.open('ru', encoding='utf-8') except ValueError: # We are using Windows - translation_file = locale_path.open('r') + translation_file = locale_path.open('r', encoding='utf-8') self._parse(translation_file) except (IOError, FileNotFoundError): # The translation is unavailable pass