From a26a60ba49dc79acee31fe0e605341fb22c146a9 Mon Sep 17 00:00:00 2001 From: caomingpei Date: Thu, 9 May 2024 17:48:52 +0800 Subject: [PATCH] !B: fix encoding issue for other characters set Fix this https://github.com/fralau/mkdocs-macros-plugin/issues/227 This commit is to set the encoding when open a file. It's useful for other characters set users. --- mkdocs_macros/plugin.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs_macros/plugin.py b/mkdocs_macros/plugin.py index 00aa362..d3f5b66 100644 --- a/mkdocs_macros/plugin.py +++ b/mkdocs_macros/plugin.py @@ -373,7 +373,7 @@ def _load_yaml(self): # Paths are be relative to the project root. filename = os.path.join(self.project_dir, filename) if os.path.isfile(filename): - with open(filename) as f: + with open(filename, encoding="utf-8") as f: # load the yaml file # NOTE: for the SafeLoader argument, see: https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation content = yaml.load(f, Loader=yaml.SafeLoader) diff --git a/setup.py b/setup.py index 0ceb7b5..dd5332f 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def read_file(fname): "Read a local file" - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read() setup(