jenkins-bot has submitted this change and it was merged.

Change subject: Fix bug in MonitoringProtocol._getConfigStringList
......................................................................


Fix bug in MonitoringProtocol._getConfigStringList

This code is designed to verify that `val` is a list of strings:

  type(val) == list and reduce(lambda x, y: type(x) == str and y, val)

But it doesn't work correctly if the last element isn't a string (try ['abc',
123], for example) or if the last element is the empty string.

Change-Id: If4d639980c69c2ab0d46a7590f1e8c946f8fcdac
---
M pybal/monitor.py
1 file changed, 6 insertions(+), 3 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pybal/monitor.py b/pybal/monitor.py
index 57c11b3..024fc94 100644
--- a/pybal/monitor.py
+++ b/pybal/monitor.py
@@ -98,9 +98,12 @@
         val = eval(self.configuration[self.__name__.lower() + '.' + 
optionname], locals, globals)
         if type(val) == str:
             return val
-        elif type(val) == list and reduce(lambda x, y: type(x) == str and y, 
val):
-            # Checked that each list member is a string
+        elif (isinstance(val, list)
+              and all(isinstance(x, str) for x in val)
+              and val):
+            # Checked that each list member is a string and that list is not
+            # empty.
             return val
         else:
             raise ValueError, "Value of %s is not a string or stringlist" % 
optionname
-    
\ No newline at end of file
+    

-- 
To view, visit https://gerrit.wikimedia.org/r/172949
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If4d639980c69c2ab0d46a7590f1e8c946f8fcdac
Gerrit-PatchSet: 2
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to