Skip to content
This repository
Browse code

ensure config validation method 'force_list' treats empty strings as …

…empty lists

Previously a list accepting option that was set to an empty string would
generate a list with a single empty-string vaue.  This would cause
confusing errors and require additional checks to work around.

This patch ensures force_list will return an empty list of a value is
a false value. so "option = " is equivalent to "option = ,"
  • Loading branch information...
commit b6acceb341dd32e510e3a753af4cf4ef7dc3120b 1 parent 6e3333a
Andrew Garner authored February 04, 2013

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  holland/core/config/validate.py
2  holland/core/config/validate.py
@@ -1226,7 +1226,7 @@ def force_list(value, min=None, max=None):
1226 1226
     ['hello']
1227 1227
     """
1228 1228
     if not isinstance(value, (list, tuple)):
1229  
-        value = [value]
  1229
+        value = value and [value] or []
1230 1230
     return is_list(value, min, max)
1231 1231
     
1232 1232
     

0 notes on commit b6acceb

Please sign in to comment.
Something went wrong with that request. Please try again.