Skip to content

Commit a859450

Browse files
committed
Wrap exit codes imports in try-except block
Fix ImportError on non-Unix platforms
1 parent 2694420 commit a859450

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

build_docs.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import logging
2929
import logging.handlers
3030
from functools import total_ordering
31-
from os import readlink, EX_OK, EX_SOFTWARE
31+
from os import readlink
3232
import re
3333
import shlex
3434
import shutil
@@ -48,6 +48,11 @@
4848

4949
HERE = Path(__file__).resolve().parent
5050

51+
try:
52+
from os import EX_OK, EX_SOFTWARE
53+
except ImportError:
54+
EX_OK, EX_SOFTWARE = 0, 1
55+
5156
try:
5257
import sentry_sdk
5358
except ImportError:
@@ -785,14 +790,15 @@ def build(self):
785790
sphinxbuild = self.venv / "bin" / "sphinx-build"
786791
blurb = self.venv / "bin" / "blurb"
787792
# Disable cpython switchers, we handle them now:
788-
run(
789-
[
790-
"sed",
791-
"-i",
792-
"s/ *-A switchers=1//",
793-
self.checkout / "Doc" / "Makefile",
794-
]
795-
)
793+
if self.version.as_tuple() <= (3, 7):
794+
run(
795+
[
796+
"sed",
797+
"-i",
798+
"s/ *-A switchers=1//",
799+
f"'{self.checkout / 'Doc' / 'Makefile'}'",
800+
]
801+
)
796802
self.version.setup_indexsidebar(
797803
self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html"
798804
)
@@ -1053,6 +1059,8 @@ def main() -> bool:
10531059
languages_dict = {language.tag: language for language in LANGUAGES}
10541060
versions = Version.filter(VERSIONS, args.branch)
10551061
languages = [languages_dict[tag] for tag in args.languages]
1062+
if not versions:
1063+
raise ValueError(f"Branch/version {args.branch} not found")
10561064
del args.languages
10571065
del args.branch
10581066
todo = list(product(versions, languages))

0 commit comments

Comments
 (0)