From c10e4dddca32a7a74978f2938359be8a65e7e40f Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 28 Feb 2018 09:37:11 -0500 Subject: [PATCH] Don't let the system encoding screw with things, specify opens as happening with utf-8 encoding --- redbot/cogs/downloader/downloader.py | 2 +- redbot/cogs/trivia/trivia.py | 2 +- redbot/core/i18n.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) 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/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/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