jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] BlockEntry: Allow flags to be an empty str ......................................................................
[FIX] BlockEntry: Allow flags to be an empty str
When flags is an empty string it wouldn't split it and thus returning the string directly. Instead it should just return an empty list.
Bug: T101976 Change-Id: Ifc18270c5027d9fd5b76037534e477702e8429f6 --- M pywikibot/logentries.py M tests/logentry_tests.py 2 files changed, 7 insertions(+), 2 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py index 40dfb14..a639628 100644 --- a/pywikibot/logentries.py +++ b/pywikibot/logentries.py @@ -157,8 +157,11 @@ if not hasattr(self, '_flags'): self._flags = self._params['flags'] # pre mw 1.19 returned a delimited string. - if self._flags and isinstance(self._flags, basestring): - self._flags = self._flags.split(',') + if isinstance(self._flags, basestring): + if self._flags: + self._flags = self._flags.split(',') + else: + self._flags = [] return self._flags
def duration(self): diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py index 5c750e5..1b4bb8b 100644 --- a/tests/logentry_tests.py +++ b/tests/logentry_tests.py @@ -88,6 +88,8 @@ logentry = self._get_logentry('block') if logentry.action() == 'block': self.assertIsInstance(logentry.flags(), list) + # Check that there are no empty strings + self.assertTrue(all(logentry.flags())) if logentry.expiry() is not None: self.assertIsInstance(logentry.expiry(), pywikibot.Timestamp) self.assertIsInstance(logentry.duration(), datetime.timedelta)