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:
  John Vandenberg: 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 f6a1611..2326ebd 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -118,6 +118,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/217258
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: master
Gerrit-Owner: XZise <commodorefabia...@gmx.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to