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)
--
To view, visit https://gerrit.wikimedia.org/r/223867
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc18270c5027d9fd5b76037534e477702e8429f6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits