registry.Regexp: Better safeguard against misuses of _setValue()

This commit is contained in:
Valentin Lorentz 2022-01-11 20:38:44 +01:00
parent 28b28fe3cf
commit 1643cb1b09
1 changed files with 2 additions and 4 deletions

View File

@ -802,16 +802,14 @@ class Regexp(Value):
else:
super().set(v)
def setValue(self, v):
"""Don't call this function directly from plugins, it is subject
to change without notice."""
def _setValue(self, v, *args, **kwargs):
if v is not None and (not isinstance(v, tuple) or len(v) != 2):
raise InvalidRegistryValue(
'Can\'t setValue a regexp, there would be an inconsistency '
'between the regexp and the recorded string value. '
'Use .set() instead.')
super().setValue(v)
super()._setValue(v, *args, **kwargs)
def __call__(self):
value = super().__call__()