mirror of
https://github.com/element-hq/synapse.git
synced 2026-01-16 23:00:43 +00:00
Use UTF-8 for config doc generation (#18580)
This commit is contained in:
parent
f5f2c9587e
commit
a82b8a966a
2 changed files with 9 additions and 1 deletions
1
changelog.d/18580.misc
Normal file
1
changelog.d/18580.misc
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fix config documentation generation script on Windows by enforcing UTF-8.
|
||||
|
|
@ -473,6 +473,10 @@ def section(prop: str, values: dict) -> str:
|
|||
|
||||
|
||||
def main() -> None:
|
||||
# For Windows: reconfigure the terminal to be UTF-8 for `print()` calls.
|
||||
if sys.platform == "win32":
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
|
||||
def usage(err_msg: str) -> int:
|
||||
script_name = (sys.argv[:1] or ["__main__.py"])[0]
|
||||
print(err_msg, file=sys.stderr)
|
||||
|
|
@ -485,7 +489,10 @@ def main() -> None:
|
|||
exit(usage("Too many arguments."))
|
||||
if not (filepath := (sys.argv[1:] or [""])[0]):
|
||||
exit(usage("No schema file provided."))
|
||||
with open(filepath) as f:
|
||||
with open(filepath, "r", encoding="utf-8") as f:
|
||||
# Note: Windows requires that we specify the encoding otherwise it uses
|
||||
# things like CP-1251, which can cause explosions.
|
||||
# See https://github.com/yaml/pyyaml/issues/123 for more info.
|
||||
return yaml.safe_load(f)
|
||||
|
||||
schema = read_json_file_arg()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue