XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/217258

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/58/217258/1

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: newchange
Gerrit-Change-Id: Ifc18270c5027d9fd5b76037534e477702e8429f6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to