Skip to content

Commit f1e5468

Browse files
committed
improve version string validation in version_info_templater.py
1 parent b7a523f commit f1e5468

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

builder/version_info_templater.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@
3131

3232
# Define a regular expression pattern to match the version string
3333
pattern = re.compile(r"(\d+)\.(\d+)\.(\d+)")
34-
semver = pattern.match(__about__.__version__).groups()
34+
match = pattern.search(__about__.__version__)
35+
if match:
36+
semver = match.groups()
37+
else:
38+
raise ValueError(
39+
f"Invalid version format: {__about__.__version__}. "
40+
"Expected at least 'X.Y.Z' at the start."
41+
)
3542

3643

3744
REPLACEMENT_VALUES = {

0 commit comments

Comments
 (0)