@@ -463,7 +463,7 @@ def setup_switchers(script_content: bytes, html_root: Path) -> None:
463463 - Cross-link various versions in a version switcher
464464 """
465465 switchers_path = html_root / "_static" / "switchers.js"
466- switchers_path .write_text (script_content , encoding = "UTF-8" )
466+ switchers_path .write_bytes (script_content )
467467
468468 for file in html_root .glob ("**/*.html" ):
469469 depth = len (file .relative_to (html_root ).parts ) - 1
@@ -910,20 +910,21 @@ def _checkout_name(select_output: str | None) -> str:
910910 return "cpython"
911911
912912
913- def main () -> None :
913+ def main () -> int :
914914 """Script entry point."""
915915 args = parse_args ()
916916 setup_logging (args .log_directory , args .select_output )
917917 load_environment_variables ()
918918
919919 if args .select_output is None :
920- build_docs_with_lock (args , "build_docs.lock" )
921- elif args .select_output == "no-html" :
922- build_docs_with_lock (args , "build_docs_archives.lock" )
923- elif args .select_output == "only-html" :
924- build_docs_with_lock (args , "build_docs_html.lock" )
925- elif args .select_output == "only-html-en" :
926- build_docs_with_lock (args , "build_docs_html_en.lock" )
920+ return build_docs_with_lock (args , "build_docs.lock" )
921+ if args .select_output == "no-html" :
922+ return build_docs_with_lock (args , "build_docs_archives.lock" )
923+ if args .select_output == "only-html" :
924+ return build_docs_with_lock (args , "build_docs_html.lock" )
925+ if args .select_output == "only-html-en" :
926+ return build_docs_with_lock (args , "build_docs_html_en.lock" )
927+ return EX_FAILURE
927928
928929
929930def parse_args () -> argparse .Namespace :
@@ -1072,12 +1073,12 @@ def build_docs_with_lock(args: argparse.Namespace, lockfile_name: str) -> int:
10721073 return EX_FAILURE
10731074
10741075 try :
1075- return EX_OK if build_docs (args ) else EX_FAILURE
1076+ return build_docs (args )
10761077 finally :
10771078 lock .close ()
10781079
10791080
1080- def build_docs (args : argparse .Namespace ) -> bool :
1081+ def build_docs (args : argparse .Namespace ) -> int :
10811082 """Build all docs (each language and each version)."""
10821083 logging .info ("Full build start." )
10831084 start_time = perf_counter ()
@@ -1160,7 +1161,7 @@ def build_docs(args: argparse.Namespace) -> bool:
11601161
11611162 logging .info ("Full build done (%s)." , format_seconds (perf_counter () - start_time ))
11621163
1163- return any_build_failed
1164+ return EX_FAILURE if any_build_failed else EX_OK
11641165
11651166
11661167def parse_versions_from_devguide (http : urllib3 .PoolManager ) -> Versions :
@@ -1404,4 +1405,4 @@ def purge_surrogate_key(http: urllib3.PoolManager, surrogate_key: str) -> None:
14041405
14051406
14061407if __name__ == "__main__" :
1407- sys . exit (main ())
1408+ raise SystemExit (main ())
0 commit comments