diff options
author | Joshua Harlow <jxharlow@godaddy.com> | 2016-10-21 14:38:03 -0700 |
---|---|---|
committer | Adam Harwell <flux.adam@gmail.com> | 2016-10-25 10:20:21 +0200 |
commit | 0be235e46b5a238bfbf13b44349a5898887f1d73 (patch) | |
tree | eed8d3d633b37de9892d1a1fffd4a5a40249d0f1 /oslo_config/types.py | |
parent | 33018edc398dc93506f54d2ab29478d14b8f0814 (diff) | |
download | oslo-config-0be235e46b5a238bfbf13b44349a5898887f1d73.tar.gz |
Fixup list types handling tuples
The addition to enforce_type now tries to convert the
value (even if enforcing is off) which can result in
types the list class was not handling now being handled.
One example is someone setting an override for a tuple
go through the same code path as for lists.
Related-Bug: #1635717
Co-Authored-By: Adam Harwell <flux.adam@gmail.com>
Change-Id: Icdce83d731642724ea3ce6920b84c25d61bd63c5
Diffstat (limited to 'oslo_config/types.py')
-rw-r--r-- | oslo_config/types.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/oslo_config/types.py b/oslo_config/types.py index e4f4e02..9a3bda1 100644 --- a/oslo_config/types.py +++ b/oslo_config/types.py @@ -440,23 +440,24 @@ class List(ConfigType): self.bounds = bounds def __call__(self, value): - if isinstance(value, list): - return value + if isinstance(value, (list, tuple)): + return list(value) - result = [] s = value.strip() - if self.bounds: if not s.startswith('['): raise ValueError('Value should start with "["') if not s.endswith(']'): raise ValueError('Value should end with "]"') s = s[1:-1] + if s: + values = s.split(',') + else: + values = [] + if not values: + return [] - if s == '': - return result - - values = s.split(',') + result = [] while values: value = values.pop(0) while True: |