Unverified Commit 8ee8f696 authored by WRH's avatar WRH Committed by GitHub
Browse files

[Fix] Read in rb mode then decode (#983)



* read in rb mode then decode

* Update config.py

* Update .pre-commit-config.yaml

* Update config.py

* Update config.py
Co-authored-by: default avatarWenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
parent b1df16a4
......@@ -90,7 +90,8 @@ class Config:
@staticmethod
def _validate_py_syntax(filename):
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
# Setting encoding explicitly to resolve coding issue on windows
content = f.read()
try:
ast.parse(content)
......@@ -109,7 +110,8 @@ class Config:
fileBasename=file_basename,
fileBasenameNoExtension=file_basename_no_extension,
fileExtname=file_extname)
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
# Setting encoding explicitly to resolve coding issue on windows
config_file = f.read()
for key, value in support_templates.items():
regexp = r'\{\{\s*' + str(key) + r'\s*\}\}'
......@@ -159,7 +161,8 @@ class Config:
temp_config_file.close()
cfg_text = filename + '\n'
with open(filename, 'r') as f:
with open(filename, 'r', encoding='utf-8') as f:
# Setting encoding explicitly to resolve coding issue on windows
cfg_text += f.read()
if BASE_KEY in cfg_dict:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment