summaryrefslogtreecommitdiff
path: root/qutebrowser/utils/utils.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-02-10 12:04:06 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-02-10 16:13:22 +0100
commit382c94a8967d9bb662fcde7601b6ae14f530b935 (patch)
tree59b7a65f0b71c6ce348e146374cdebfc144b70cd /qutebrowser/utils/utils.py
parent2214b8fff9dd79dd4df83cea0736a660b511c323 (diff)
downloadqutebrowser-382c94a8967d9bb662fcde7601b6ae14f530b935.tar.gz
qutebrowser-382c94a8967d9bb662fcde7601b6ae14f530b935.zip
Ensure explicitly constructed versions numbers are normalized
Diffstat (limited to 'qutebrowser/utils/utils.py')
-rw-r--r--qutebrowser/utils/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index 73d3143d3..000953d8b 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -101,6 +101,14 @@ else:
"""We can't inherit from Protocol and QVersionNumber at runtime."""
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ normalized = self.normalized()
+ if normalized != self:
+ raise ValueError(
+ f"Refusing to construct non-normalized version from {args} "
+ f"(normalized: {tuple(normalized.segments())}).")
+
def __repr__(self):
args = ", ".join(str(s) for s in self.segments())
return f'VersionNumber({args})'