File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Fix config documentation generation script on Windows by enforcing UTF-8.
Original file line number Diff line number Diff line change @@ -473,6 +473,10 @@ def post_description() -> str:
473473
474474
475475def main () -> None :
476+ # For Windows: reconfigure the terminal to be UTF-8 for `print()` calls.
477+ if sys .platform == "win32" :
478+ sys .stdout .reconfigure (encoding = "utf-8" )
479+
476480 def usage (err_msg : str ) -> int :
477481 script_name = (sys .argv [:1 ] or ["__main__.py" ])[0 ]
478482 print (err_msg , file = sys .stderr )
@@ -485,7 +489,10 @@ def read_json_file_arg() -> Any:
485489 exit (usage ("Too many arguments." ))
486490 if not (filepath := (sys .argv [1 :] or ["" ])[0 ]):
487491 exit (usage ("No schema file provided." ))
488- with open (filepath ) as f :
492+ with open (filepath , "r" , encoding = "utf-8" ) as f :
493+ # Note: Windows requires that we specify the encoding otherwise it uses
494+ # things like CP-1251, which can cause explosions.
495+ # See https://github.com/yaml/pyyaml/issues/123 for more info.
489496 return yaml .safe_load (f )
490497
491498 schema = read_json_file_arg ()
You can’t perform that action at this time.
0 commit comments