Compare commits

...

3 Commits

Author SHA1 Message Date
Travis Ralston
8e5c65f66a limit to windows 2025-06-19 12:12:53 -06:00
Travis Ralston
c7d0a69065 changelog 2025-06-19 11:58:12 -06:00
Travis Ralston
1f11a1586b Use UTF-8 for config doc generation
This fixes the issue on Windows, which uses CP-1251 by default.
2025-06-19 11:57:01 -06:00
2 changed files with 9 additions and 1 deletions

1
changelog.d/18580.misc Normal file
View File

@@ -0,0 +1 @@
Fix config documentation generation script on Windows by enforcing UTF-8.

View File

@@ -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='utf8') 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()