registry: Fix regression preventing default None value for Regexp.

This commit is contained in:
Valentin Lorentz 2020-09-05 22:02:53 +02:00
parent 6a3be33fcd
commit 23417b0675
2 changed files with 9 additions and 5 deletions

View File

@ -768,17 +768,23 @@ class Regexp(Value):
# value of there parent change.
v = (s, utils.str.perlReToPythonRe(s))
else:
v = ('', '')
v = None
except ValueError as e:
self.error(e)
else:
super().set(v)
def __call__(self):
return self.value[1]
if self.value is None:
return None
else:
return self.value[1]
def __str__(self):
return self.value[0]
if self.value is None:
return ''
else:
return self.value[0]
class SeparatedListOf(Value):
__slots__ = ()

View File

@ -182,8 +182,6 @@ class ValuesTestCase(SupyTestCase):
self.assertTrue(v().match('foo'))
v.set('')
self.assertEqual(v(), None)
self.assertRaises(registry.InvalidRegistryValue,
v.setValue, re.compile(r'foo'))
def testBackslashesKeys(self):
conf.supybot.reply.whenAddressedBy.strings.get(':foo').set('=/*')